Windows: Use correct default font when desktopSettingsAware is false

The DirectWrite engine had hardcoded a default font instead of checking
the system settings for this.

Usually this will not matter, since the theme will call
QWindowsFontDatabase::systemDefaultFont() to get the default, but when
this code path is disabled by setting
QGuiApplication::desktopSettingsAware to false, the defaultFont()
function is called. With DirectWrite we would always return a Segoe UI
font of size 16 in this case.

The other databases respect the system settings for the default font,
even when desktopSettingsAware is set to false, so this is the expected
behavior. It is also what the GDI font database does, so this change
will appear as a regression for users upgrading.

[ChangeLog][Windows] Fixed a regression where the default font on
Windows would be larger than before if desktopSettingsAware had been set
to false.

Fixes: QTBUG-129832
Change-Id: I959e7a52680678a6ab767b49ee643fade5e7209a
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
(cherry picked from commit b09fb51e7bb576137f92d4697f9f812f3dcb2b7a)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
bb10
Eskil Abrahamsen Blomfeldt 2024-10-10 08:02:39 +02:00 committed by Qt Cherry-pick Bot
parent 8375adcbe4
commit 5c675fb298
2 changed files with 0 additions and 6 deletions

View File

@ -789,11 +789,6 @@ void QWindowsDirectWriteFontDatabase::populateFontDatabase()
}
}
QFont QWindowsDirectWriteFontDatabase::defaultFont() const
{
return QFont(QStringLiteral("Segoe UI"));
}
bool QWindowsDirectWriteFontDatabase::supportsVariableApplicationFonts() const
{
QSharedPointer<QWindowsFontEngineData> fontEngineData = data();

View File

@ -45,7 +45,6 @@ public:
QFontEngine *fontEngine(const QByteArray &fontData, qreal pixelSize, QFont::HintingPreference hintingPreference) override;
QStringList fallbacksForFamily(const QString &family, QFont::Style style, QFont::StyleHint styleHint, QChar::Script script) const override;
QStringList addApplicationFont(const QByteArray &fontData, const QString &fileName, QFontDatabasePrivate::ApplicationFont *font = nullptr) override;
QFont defaultFont() const override;
bool isPrivateFontFamily(const QString &family) const override;
bool supportsVariableApplicationFonts() const override;