Properly display legends on Windows, close #2251