From 6afdbfdaafcc4d24e08357dfea96b85787efb1f7 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Mon, 29 Apr 2019 22:45:14 +0200 Subject: Use "monospace" as fallback system FixedFont in KDE theme; logging Also de-duplicate the "monospace" string in qgenericunixthemes.cpp, and add tst_QFontDatabase::systemFixedFont() to verify that QFontDatabase::systemFont(QFontDatabase::FixedFont) really returns a monospace font across platforms. Replace commented-out qDebug()s with qt.text.font.match and qt.text.font.db logging categories to troubleshoot when the test fails (among other uses). Add qt.qpa.fonts logging category to unix themes to show default system and fixed fonts (font engines on other platforms are already using this category). Fixes: QTBUG-54623 Change-Id: I2aa62b8c783d9ddb591a5e06e8df85c4af5bcb0c Reviewed-by: Friedemann Kleint --- .../themes/genericunix/qgenericunixthemes.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'src/platformsupport/themes/genericunix/qgenericunixthemes.cpp') diff --git a/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp b/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp index 1003812767..6db25a90da 100644 --- a/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp +++ b/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp @@ -76,6 +76,7 @@ QT_BEGIN_NAMESPACE Q_DECLARE_LOGGING_CATEGORY(qLcTray) +Q_LOGGING_CATEGORY(lcQpaFonts, "qt.qpa.fonts") ResourceHelper::ResourceHelper() { @@ -96,6 +97,7 @@ const char *QGenericUnixTheme::name = "generic"; // Default system font, corresponding to the value returned by 4.8 for // XRender/FontConfig which we can now assume as default. static const char defaultSystemFontNameC[] = "Sans Serif"; +static const char defaultFixedFontNameC[] = "monospace"; enum { defaultSystemFontSize = 9 }; #if !defined(QT_NO_DBUS) && !defined(QT_NO_SYSTEMTRAYICON) @@ -136,9 +138,10 @@ public: QGenericUnixThemePrivate() : QPlatformThemePrivate() , systemFont(QLatin1String(defaultSystemFontNameC), defaultSystemFontSize) - , fixedFont(QStringLiteral("monospace"), systemFont.pointSize()) + , fixedFont(QLatin1String(defaultFixedFontNameC), systemFont.pointSize()) { fixedFont.setStyleHint(QFont::TypeWriter); + qCDebug(lcQpaFonts) << "default fonts: system" << systemFont << "fixed" << fixedFont; } const QFont systemFont; @@ -390,7 +393,7 @@ void QKdeThemePrivate::refresh() if (QFont *fixedFont = kdeFont(readKdeSetting(QStringLiteral("fixed"), kdeDirs, kdeVersion, kdeSettings))) { resources.fonts[QPlatformTheme::FixedFont] = fixedFont; } else { - fixedFont = new QFont(QLatin1String(defaultSystemFontNameC), defaultSystemFontSize); + fixedFont = new QFont(QLatin1String(defaultFixedFontNameC), defaultSystemFontSize); fixedFont->setStyleHint(QFont::TypeWriter); resources.fonts[QPlatformTheme::FixedFont] = fixedFont; } @@ -403,6 +406,8 @@ void QKdeThemePrivate::refresh() if (QFont *toolBarFont = kdeFont(readKdeSetting(QStringLiteral("toolBarFont"), kdeDirs, kdeVersion, kdeSettings))) resources.fonts[QPlatformTheme::ToolButtonFont] = toolBarFont; + qCDebug(lcQpaFonts) << "default fonts: system" << resources.fonts[QPlatformTheme::SystemFont] + << "fixed" << resources.fonts[QPlatformTheme::FixedFont]; qDeleteAll(kdeSettings); } @@ -716,8 +721,9 @@ public: QString fontName = gtkFontName.left(split); systemFont = new QFont(fontName, size); - fixedFont = new QFont(QLatin1String("monospace"), systemFont->pointSize()); + fixedFont = new QFont(QLatin1String(defaultFixedFontNameC), systemFont->pointSize()); fixedFont->setStyleHint(QFont::TypeWriter); + qCDebug(lcQpaFonts) << "default fonts: system" << systemFont << "fixed" << fixedFont; } mutable QFont *systemFont; -- cgit v1.2.3