From 5a25804cec70810877c3f1dd431d773ec50644a2 Mon Sep 17 00:00:00 2001 From: Uwe Rathmann Date: Tue, 28 Feb 2023 16:58:08 +0100 Subject: [PATCH] disable code that does not preload the font cache with Qt6 --- support/SkinnyNamespace.cpp | 37 +++++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/support/SkinnyNamespace.cpp b/support/SkinnyNamespace.cpp index 63db79ed..377b6724 100644 --- a/support/SkinnyNamespace.cpp +++ b/support/SkinnyNamespace.cpp @@ -86,8 +86,28 @@ static bool pluginPath = initPluginPath(); #if defined( ENSURE_FONTS ) - #include - #include + #if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) + #include + #include + #endif + + static void preloadFonts() + { + #if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) + QElapsedTimer timer; + timer.start(); + + QFontDatabase(); // deprecated and doing nothing since Qt6 + + const auto elapsed = timer.elapsed(); + + if ( elapsed > 20 ) + { + qWarning() << "Loading fonts needed" << elapsed << "ms" + << "- usually because of creating a font cache."; + } + #endif + } static void initFonts() { @@ -100,18 +120,7 @@ static bool pluginPath = initPluginPath(); qputenv( env, STRING( FONTCONFIG_FILE ) ); #endif - QElapsedTimer timer; - timer.start(); - - QFontDatabase(); - - const auto elapsed = timer.elapsed(); - - if ( elapsed > 20 ) - { - qWarning() << "Loading fonts needed" << elapsed << "ms" - << "- usually because of creating a font cache."; - } + preloadFonts(); /* The default initialization in QskSkin sets up its font table