Wrong default GUI font under Windows
Like any well-behaved GUI application, MuseScore attempts to use the operating system's default GUI font for its user interface, but also allows the user to customize this font according to his or her personal preferences.
MuseScore is a cross-platform application and uses the Qt framework to do most of the heavy lifting, including querying the operating system for the default GUI font. Unfortunately, under Windows, all versions of Qt (past and present) supply the wrong font to MuseScore.
The reason Qt gets it wrong is that internally, it calls the deprecated function GetStockObject()
with the DEFAULT_GUI_FONT
argument. DEFAULT_GUI_FONT
was vestigial and obsolete even in 2005; in fact, the official documentation explicitly says so:
> It is not recommended that you employ this method to obtain the current font used by dialogs and windows.
When this function is called, it returns the “MS Shell Dlg 2” font in 8 pt. Interestingly, “MS Shell Dlg 2” is not an actual font, but rather a virtual placeholder font that is mapped to a real font called Tahoma under all supported versions of Windows. Consequently, the entire MuseScore UI is rendered in Tahoma, which has a dated design that is strongly associated with the Windows Me and Windows XP era of the early 2000s.
In 2006, with the release of Windows Vista, Microsoft introduced a new default GUI font called Segoe UI, as well as a new default size, 9 pt. For backward-compatibility reasons, Microsoft chose not to update the mapping of the “MS Shell Dlg 2” virtual placeholder font or even the implementation of GetStockObject()
. Instead, they quietly deprecated both and introduced a new way to correctly determine the default GUI font: the SystemParametersInfo()
function with the SPI_GETNONCLIENTMETRICS
argument. Not everybody noticed (coughQtcough).
On all versions of Windows from Windows Vista through Windows 10, the new method typically returns the Segoe UI font in 9 pt. Segoe UI has a more contemporary humanist design, and it has had several visual updates over the years. It helps provide a uniform look for all Windows GUI applications, and it also renders significantly better than Tahoma on high-DPI displays.
The Qt developers are now aware of this long-standing problem and have scheduled it to be fixed in Qt 6. (See QTBUG-58610 for details.) The implementation for this fix already exists in the current Qt 5.x source code but has been conditionally compiled out for the time being. Here's a relevant comment taken directly from the Qt source code:
// Qt 5 by (Qt 4) legacy uses GetStockObject(DEFAULT_GUI_FONT) to
// obtain the default GUI font (typically "MS Shell Dlg 2, 8pt"). This has been
// long deprecated; the message font of the NONCLIENTMETRICS structure obtained by
// SystemParametersInfo(SPI_GETNONCLIENTMETRICS) should be used instead (see
// QWindowsTheme::refreshFonts(), typically "Segoe UI, 9pt"), which is larger.
Fortunately, MuseScore users do not have to wait for this fix, because it can be fixed on the application side today.
There are two parts to this fix:
-
Override Qt's detection of the default GUI font with the correct method. This code will be functionally equivalent to the code already written for Qt 6, and will be implemented as a single block so that it can easily be removed in the future should MuseScore move to Qt 6.
-
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.
Side note: There has been some talk of switching from the default GUI font to a custom font in an upcoming big MuseScore visual redesign. If and when this happens, this fix will become largely moot, but it will also be harmless. In the meantime, this bug should still be fixed right away so that users can get the correct font today.
Comments
No need to worry about moving to Qt 6:
#5791.
In reply to #if (QT_VERSION < QT_VERSION… by Jojo-Schmitz
No need for a version check, as this workaround is harmless either way. We also don't know for sure that this bug will actually be fixed in in Qt 6.0.0, so it's safer to do it “unconditionally” (i.e., under Windows).
Where does that default font (and fontsize) gets set (in Windows, not in MuseScore)?
In reply to Where does that default font… by Jojo-Schmitz
The font name and size used to be directly configurable by the user, but that's no longer the case in recent versions of Windows. They can still be changed programmatically, though. Or by editing the registry.
Under Windows 10 it's still possible to change the overall font size by going to Settings | Ease of Access | Make text bigger.
Note: Neither Qt nor MuseScore watches for changes to these settings, so they won't pick anything up until you restart MuseScore. Worse, MuseScore won't pick up the new font settings even if you restart MuseScore if you've already got font settings written to your settings file (which will be the case if you've ever gone to Preferences and clicked OK — even on a different tab). In that case the only ways to pick up the changes are to edit the settings file manually to remove the font settings or to do a factory reset. But that's another issue for another day.
now https://github.com/musescore/MuseScore/pull/5820
Refiled as #5820.
Fixed in branch master, commit a4a382c671
_Fix #302114: Wrong default GUI font under Windows
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:
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._
Fixed in branch master, commit 853c095ad8
_Merge pull request #5820 from Spire42/302114-wrong-default-GUI-font-under-Windows
Fix #302114: Wrong default GUI font under Windows_
Automatically closed -- issue fixed for 2 weeks with no activity.