diff options
author | Morten Sørvig <morten.sorvig@qt.io> | 2022-11-18 15:54:56 +0100 |
---|---|---|
committer | Morten Sørvig <morten.sorvig@qt.io> | 2022-11-30 12:52:56 +0100 |
commit | ca0f0a43e9df19f0baa825c994061609a65b863e (patch) | |
tree | b37f85f1a052a08f91d898d541999f1e3d0a0016 | |
parent | 192330439a5154ed7a6b5a7e2b4b7e9a62712491 (diff) | |
download | qtbase-ca0f0a43e9df19f0baa825c994061609a65b863e.tar.gz |
win: resolve theme fonts at 96 dpi
This code became out of sync with the changes to the
LOGFONT_to_QFont() implementation introduced in edb00660.
After that, LOGFONT_to_QFont() on longer adjusts the font size
according to the DPI for the primary display. This means that
the the code should also not get font metrics from the first
display, but instead get metrics at 96 DPI.
Fixes: QTBUG-105857
Change-Id: I5974a77593e1944d889a45a352923fb9aa9a0dec
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
(cherry picked from commit 64bb83f882391fbfd4bf88ce5673b3f1c82bfdf6)
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
-rw-r--r-- | src/plugins/platforms/windows/qwindowstheme.cpp | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/src/plugins/platforms/windows/qwindowstheme.cpp b/src/plugins/platforms/windows/qwindowstheme.cpp index c15ab82a8b..66d261174c 100644 --- a/src/plugins/platforms/windows/qwindowstheme.cpp +++ b/src/plugins/platforms/windows/qwindowstheme.cpp @@ -643,20 +643,22 @@ void QWindowsTheme::refreshFonts() clearFonts(); if (!QGuiApplication::desktopSettingsAware()) return; + + const int dpi = 96; NONCLIENTMETRICS ncm; - auto &screenManager = QWindowsContext::instance()->screenManager(); - QWindowsContext::nonClientMetricsForScreen(&ncm, screenManager.screens().value(0)); + QWindowsContext::nonClientMetrics(&ncm, dpi); qCDebug(lcQpaWindows) << __FUNCTION__ << ncm; - const QFont menuFont = QWindowsFontDatabase::LOGFONT_to_QFont(ncm.lfMenuFont); - const QFont messageBoxFont = QWindowsFontDatabase::LOGFONT_to_QFont(ncm.lfMessageFont); - const QFont statusFont = QWindowsFontDatabase::LOGFONT_to_QFont(ncm.lfStatusFont); - const QFont titleFont = QWindowsFontDatabase::LOGFONT_to_QFont(ncm.lfCaptionFont); + const QFont menuFont = QWindowsFontDatabase::LOGFONT_to_QFont(ncm.lfMenuFont, dpi); + const QFont messageBoxFont = QWindowsFontDatabase::LOGFONT_to_QFont(ncm.lfMessageFont, dpi); + const QFont statusFont = QWindowsFontDatabase::LOGFONT_to_QFont(ncm.lfStatusFont, dpi); + const QFont titleFont = QWindowsFontDatabase::LOGFONT_to_QFont(ncm.lfCaptionFont, dpi); + QFont fixedFont(QStringLiteral("Courier New"), messageBoxFont.pointSize()); fixedFont.setStyleHint(QFont::TypeWriter); LOGFONT lfIconTitleFont; - SystemParametersInfo(SPI_GETICONTITLELOGFONT, sizeof(lfIconTitleFont), &lfIconTitleFont, 0); - const QFont iconTitleFont = QWindowsFontDatabase::LOGFONT_to_QFont(lfIconTitleFont); + SystemParametersInfoForDpi(SPI_GETICONTITLELOGFONT, sizeof(lfIconTitleFont), &lfIconTitleFont, 0, dpi); + const QFont iconTitleFont = QWindowsFontDatabase::LOGFONT_to_QFont(lfIconTitleFont, dpi); m_fonts[SystemFont] = new QFont(QWindowsFontDatabase::systemDefaultFont()); m_fonts[MenuFont] = new QFont(menuFont); |