From 5c675fb2988fada78b3cd4f688cf865e852291c6 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Thu, 10 Oct 2024 08:02:39 +0200 Subject: [PATCH] Windows: Use correct default font when desktopSettingsAware is false MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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ø (cherry picked from commit b09fb51e7bb576137f92d4697f9f812f3dcb2b7a) Reviewed-by: Qt Cherry-pick Bot --- src/gui/text/windows/qwindowsdirectwritefontdatabase.cpp | 5 ----- src/gui/text/windows/qwindowsdirectwritefontdatabase_p.h | 1 - 2 files changed, 6 deletions(-) diff --git a/src/gui/text/windows/qwindowsdirectwritefontdatabase.cpp b/src/gui/text/windows/qwindowsdirectwritefontdatabase.cpp index 5674f766de..2a6b1a53f9 100644 --- a/src/gui/text/windows/qwindowsdirectwritefontdatabase.cpp +++ b/src/gui/text/windows/qwindowsdirectwritefontdatabase.cpp @@ -789,11 +789,6 @@ void QWindowsDirectWriteFontDatabase::populateFontDatabase() } } -QFont QWindowsDirectWriteFontDatabase::defaultFont() const -{ - return QFont(QStringLiteral("Segoe UI")); -} - bool QWindowsDirectWriteFontDatabase::supportsVariableApplicationFonts() const { QSharedPointer fontEngineData = data(); diff --git a/src/gui/text/windows/qwindowsdirectwritefontdatabase_p.h b/src/gui/text/windows/qwindowsdirectwritefontdatabase_p.h index 093c629a16..3b2bba4d7b 100644 --- a/src/gui/text/windows/qwindowsdirectwritefontdatabase_p.h +++ b/src/gui/text/windows/qwindowsdirectwritefontdatabase_p.h @@ -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;