-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix #302114: Wrong default GUI font under Windows #5820
Fix #302114: Wrong default GUI font under Windows #5820
Conversation
Worked around a problem in Qt that caused MuseScore to use the wrong default GUI font on Windows. Qt 5.x and below use the deprecated function GetStockObject() with DEFAULT_GUI_FONT, which returns MS Shell Dlg 2 in 8 pt. MS Shell Dlg 2 is a virtual font that maps to Tahoma, which has not been the default Windows GUI font since 2006. The correct way to determine the default GUI font is to call SystemParametersInfoW() with SPI_GETNONCLIENTMETRICS and use the returned lfMessageFont structure. On all versions of Windows from Windows Vista through Windows 10, this typically returns Segoe UI in 9 pt. This problem is slated to be fixed in Qt 6. For details, see: https://bugreports.qt.io/browse/QTBUG-58610 In the meantime, we can work around the problem by having Qt use the "QMessageBox" font instead, which is already being initialized the correct way. There are two parts to this fix: 1. Override Qt's detection of the default GUI font. To do this, we ask Qt for the "QMessageBox" font and then tell Qt to use that as the default GUI font as well. 2. Detect existing settings files that have been saved with the incorrect default GUI font, and reset the incorrect font settings so that the correct font can be picked up automatically by existing MuseScore installations. Note that this will have the side effect of making the MS Shell Dlg 2 font no longer “stick” if the user explicitly selects it. However, this is a virtual placeholder font that shouldn't be explicitly selected anyway, and any users who prefer its look can always explicitly select the actual underlying font, Tahoma.
9ddc8ce
to
a4a382c
Compare
// | ||
// In the meantime, we can work around the problem by having Qt use the "QMessageBox" font instead, which is already being | ||
// initialized the correct way. | ||
QApplication::setFont(QApplication::font("QMessageBox")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also would it be better to move this line into the if()
statement below? Then it seems this fix wouldn't affect those installations which do not have this issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, these are two separate fixes.
Due to the bug in Qt, the default QApplication
font will always be incorrect under Windows, no matter what is currently saved in the settings. If we moved this line into the if
statement below, a fresh (or freshly factory-reset) installation of MuseScore would always be initialized with the wrong default font, which would render this fix useless.
The code inside the if
statement is handling the specific case where the wrong default font has already been saved to the settings in the past. After we fix the default QApplication
font, we check to see if the settings has the bad font saved; if so, we reset the font in the settings so that the correct default font (which we've just fixed with the QApplication::setFont()
call) can be picked up.
Resolves: #302114
Worked around a problem in Qt that caused MuseScore to use the wrong default GUI font on Windows. Qt 5.x and below use the deprecated function
GetStockObject()
withDEFAULT_GUI_FONT
, which returns MS Shell Dlg 2 in 8 pt. MS Shell Dlg 2 is a virtual font that maps to Tahoma, which has not been the default Windows GUI font since 2006.The correct way to determine the default GUI font is to call
SystemParametersInfoW()
withSPI_GETNONCLIENTMETRICS
and use the returnedlfMessageFont
structure. On all versions of Windows from Windows Vista through Windows 10, this typically returns Segoe UI in 9 pt.This problem is slated to be fixed in Qt 6. For details, see QTBUG-58610.
In the meantime, we can work around the problem by having Qt use the
"QMessageBox"
font instead, which is already being initialized the correct way.There are two parts to this fix:
Override Qt's detection of the default GUI font. To do this, we ask Qt for the
"QMessageBox"
font and then tell Qt to use that as the default GUI font as well.Detect existing settings files that have been saved with the incorrect default GUI font, and reset the incorrect font settings so that the correct font can be picked up automatically by existing MuseScore installations. Note that this will have the side effect of making the MS Shell Dlg 2 font no longer “stick” if the user explicitly selects it. However, this is a virtual placeholder font that shouldn't be explicitly selected anyway, and any users who prefer its look can always explicitly select the actual underlying font, Tahoma.
[Note: This is a corrected version of PR #5791.]