From 9b88abdeeee32ddda5a07fe669ad8b0a1ef307c7 Mon Sep 17 00:00:00 2001 From: Mark Liversedge Date: Tue, 30 May 2023 08:28:38 +0100 Subject: [PATCH] Search QFontDatabase for installed fonts .. instead of trying to create a font and use exactMatch() .. this is faster and also avoids a qt-bug on MacOS for QFont::exactMatch() that keeps recurring --- src/Core/Settings.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/Core/Settings.cpp b/src/Core/Settings.cpp index 8d752e77c..c18fc51ec 100644 --- a/src/Core/Settings.cpp +++ b/src/Core/Settings.cpp @@ -25,6 +25,8 @@ #include #include +#include + #ifdef Q_OS_MAC int OperatingSystem = OSX; #elif defined Q_OS_WIN32 @@ -771,14 +773,21 @@ GSettings::defaultAppearanceSettings() // lets find an appropriate font returning.fontfamily = QFont().toString(); // ultimately fall back to QT default + QFontDatabase fontdb; for(int i=0; fontfamilyfallback[i] != NULL; i++) { - QFont font(fontfamilyfallback[i]); - if (font.exactMatch()) { - returning.fontfamily = fontfamilyfallback[i]; - break; + foreach(QString family, fontdb.families()) { + + // is it installed ? + if (family == fontfamilyfallback[i]) { + returning.fontfamily = fontfamilyfallback[i]; + goto breakout; + } } } + +breakout: + returning.fontpointsize = 11; // default // scaling only applies on hidpi displays