diff --git a/designsystems/fluent2/QskFluent2Skin.cpp b/designsystems/fluent2/QskFluent2Skin.cpp index 6ef5a14a..ba49766b 100644 --- a/designsystems/fluent2/QskFluent2Skin.cpp +++ b/designsystems/fluent2/QskFluent2Skin.cpp @@ -100,8 +100,8 @@ #include #include -#include -#include +#include +#include namespace Fluent2 { @@ -2050,7 +2050,19 @@ static inline QFont createFont( int size, int lineHeight, QFont::Weight weight ) "This value is always equal to leading()+height()" */ - QFont font( QStringLiteral( "Segoe UI Variable" ), -1, weight ); + QFont font( QStringLiteral( "Segoe UI" ), -1, weight ); + + static bool checkFont = true; + if ( checkFont ) + { + const QFontInfo info( font ); + if ( info.family() != font.family() ) + { + qWarning() << font.family() << + "not found, using" << info.family() << "instead."; + } + checkFont = false; + } // sp: this is like the dp unit, but it is also scaled by the user's font size preference font.setPixelSize( pixelSize ); diff --git a/designsystems/material3/QskMaterial3Skin.cpp b/designsystems/material3/QskMaterial3Skin.cpp index b9139e26..81c4ce6a 100644 --- a/designsystems/material3/QskMaterial3Skin.cpp +++ b/designsystems/material3/QskMaterial3Skin.cpp @@ -56,8 +56,8 @@ #include #include -#include -#include +#include +#include static const int qskDuration = 150; @@ -1444,6 +1444,19 @@ static inline QFont createFont( int size, int lineHeight, const int pixelSize = qRound( qskDpToPixels( lineHeight ) ); QFont font( QStringLiteral( "Roboto" ), -1, weight ); + + static bool checkFont = true; + if ( checkFont ) + { + const QFontInfo info( font ); + if ( info.family() != font.family() ) + { + qWarning() << font.family() << + "not found, using" << info.family() << "instead."; + } + checkFont = false; + } + font.setPixelSize( pixelSize ); if ( spacing > 0.0 ) diff --git a/examples/iotdashboard/Skin.cpp b/examples/iotdashboard/Skin.cpp index 0b0b2626..5e7b56e3 100644 --- a/examples/iotdashboard/Skin.cpp +++ b/examples/iotdashboard/Skin.cpp @@ -72,8 +72,7 @@ void Skin::initHints() { const auto palette = Skin::palette( colorScheme() ); - QFontDatabase db; - db.addApplicationFont( ":/fonts/ProximaNova-Regular.otf" ); // ### use fontconfig + QFontDatabase::addApplicationFont( ":/fonts/ProximaNova-Regular.otf" ); setFont( { QskFontRole::Caption, QskFontRole::Low }, createFont( 9 ) ); setFont( { QskFontRole::Caption, QskFontRole::Normal }, createFont( 10 ) ); diff --git a/support/CMakeLists.txt b/support/CMakeLists.txt index 7d005444..9666ea99 100644 --- a/support/CMakeLists.txt +++ b/support/CMakeLists.txt @@ -11,6 +11,8 @@ set(SOURCES SkinnyShortcut.h SkinnyShortcut.cpp ) +qt_add_resources(SOURCES fonts.qrc) + set(target qsktestsupport) if (BUILD_QSKDLL) @@ -32,30 +34,8 @@ target_include_directories(${target} PUBLIC ${CMAKE_CURRENT_LIST_DIR}) if(ENABLE_ENSURE_SKINS) target_include_directories(${target} PRIVATE ${QSK_SOURCE_DIR}/designsystems) - target_compile_definitions(${target} PRIVATE ENSURE_SKINS) + target_compile_definitions(${target} PRIVATE ENSURE_SKINS ENSURE_FONTS) target_link_libraries(${target} PRIVATE material3skin fluent2skin fusionskin) endif() -set(HIDE_SYSTEM_FONTS ON) - -if(HIDE_SYSTEM_FONTS) - message( STATUS "Hiding system fonts from the examples" ) - - # The fonts being used in the examples are included and we do not - # need the fonts from the system. To avoid, that setting up the font - # cache slows doesn the stratup performance we hide the system fonts - # be using a dummy font config environment. - # ( this hack is pretty old ( Qt 5.4 ) - maybe it is not needed anymore TODO ) - - set(QSK_FONTDIR ${CMAKE_CURRENT_LIST_DIR}/fonts) - set(QSK_FONTCACHEDIR ${CMAKE_CURRENT_BINARY_DIR}/fontconfig) - set(QSK_FONTCONF_FILE ${QSK_FONTCACHEDIR}/fonts.conf) - - configure_file(fonts.conf.cmake.in ${QSK_FONTCONF_FILE} - @ONLY NEWLINE_STYLE LF) - - target_compile_definitions(${target} - PRIVATE FONTCONFIG_FILE=${QSK_FONTCONF_FILE}) -endif() - set_target_properties(${target} PROPERTIES FOLDER libs) diff --git a/support/SkinnyNamespace.cpp b/support/SkinnyNamespace.cpp index ec0d95bc..36377448 100644 --- a/support/SkinnyNamespace.cpp +++ b/support/SkinnyNamespace.cpp @@ -11,16 +11,12 @@ #include #include +#include #include #include -#define STRINGIFY(x) #x -#define STRING(x) STRINGIFY(x) - #if defined( PLUGIN_PATH ) -#include - #define STRINGIFY(x) #x #define STRING(x) STRINGIFY(x) @@ -77,58 +73,30 @@ static bool pluginPath = initPluginPath(); } Q_COREAPP_STARTUP_FUNCTION( initSkins ) - #endif -#define ENSURE_FONTS - #if defined( ENSURE_FONTS ) - #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 - } + #include static void initFonts() { - if ( !qobject_cast< QGuiApplication* >( qApp ) ) - return; // no fonts needed + const QString path = QStringLiteral( ":/fonts/" ); - #ifdef FONTCONFIG_FILE - const char env[] = "FONTCONFIG_FILE"; - if ( !qEnvironmentVariableIsSet( env ) ) - qputenv( env, STRING( FONTCONFIG_FILE ) ); - #endif + QDir dir( path ); + const auto fontFiles = dir.entryList(); - preloadFonts(); - - /* - The default initialization in QskSkin sets up its font table - with using the application font for the default font role. - */ - QGuiApplication::setFont( QFont( "DejaVuSans", 12 ) ); + for ( const auto& file : fontFiles ) + { + const auto fontPath = path + file; + if ( QFontDatabase::addApplicationFont( fontPath ) < 0 ) + qWarning() << "couldn't load font file:" << fontPath; + } } -#endif -Q_COREAPP_STARTUP_FUNCTION( initFonts ) + Q_COREAPP_STARTUP_FUNCTION( initFonts ) + +#endif void Skinny::changeSkin() { diff --git a/support/fonts.conf.cmake.in b/support/fonts.conf.cmake.in deleted file mode 100644 index 501a1fa0..00000000 --- a/support/fonts.conf.cmake.in +++ /dev/null @@ -1,6 +0,0 @@ - - - - @QSK_FONTDIR@ - @QSK_FONTCACHEDIR@/cache - diff --git a/support/fonts.qrc b/support/fonts.qrc new file mode 100644 index 00000000..1a42a3c2 --- /dev/null +++ b/support/fonts.qrc @@ -0,0 +1,36 @@ + + + + fonts/DejaVuSans/DejaVuSans.ttf + + fonts/Roboto/Roboto-BlackItalic.ttf + fonts/Roboto/Roboto-Black.ttf + fonts/Roboto/Roboto-BoldItalic.ttf + fonts/Roboto/Roboto-Bold.ttf + fonts/Roboto/Roboto-Italic.ttf + fonts/Roboto/Roboto-LightItalic.ttf + fonts/Roboto/Roboto-Light.ttf + fonts/Roboto/Roboto-MediumItalic.ttf + fonts/Roboto/Roboto-Medium.ttf + fonts/Roboto/Roboto-Regular.ttf + fonts/Roboto/Roboto-ThinItalic.ttf + fonts/Roboto/Roboto-Thin.ttf + + fonts/SegoeUI/segoeuib.ttf + fonts/SegoeUI/segoeuii.ttf + fonts/SegoeUI/segoeuil.ttf + fonts/SegoeUI/segoeuisl.ttf + fonts/SegoeUI/segoeui.ttf + fonts/SegoeUI/segoeuiz.ttf + fonts/SegoeUI/seguibli.ttf + fonts/SegoeUI/seguibl.ttf + fonts/SegoeUI/seguiemj.ttf + fonts/SegoeUI/seguihis.ttf + fonts/SegoeUI/seguili.ttf + fonts/SegoeUI/seguisbi.ttf + fonts/SegoeUI/seguisb.ttf + fonts/SegoeUI/seguisli.ttf + fonts/SegoeUI/seguisym.ttf + + + diff --git a/support/fonts/DejaVuSans.ttf b/support/fonts/DejaVuSans/DejaVuSans.ttf similarity index 100% rename from support/fonts/DejaVuSans.ttf rename to support/fonts/DejaVuSans/DejaVuSans.ttf diff --git a/support/fonts/LICENSE-DejaVuSans b/support/fonts/DejaVuSans/LICENSE.txt similarity index 100% rename from support/fonts/LICENSE-DejaVuSans rename to support/fonts/DejaVuSans/LICENSE.txt diff --git a/support/fonts/LICENSE-Noto b/support/fonts/LICENSE-Noto deleted file mode 100644 index cee3f306..00000000 --- a/support/fonts/LICENSE-Noto +++ /dev/null @@ -1 +0,0 @@ -For the Noto fonts see: https://www.google.com/get/noto/ diff --git a/support/fonts/NotoSansCJKsc-Regular.otf b/support/fonts/NotoSansCJKsc-Regular.otf deleted file mode 100644 index 741201b0..00000000 Binary files a/support/fonts/NotoSansCJKsc-Regular.otf and /dev/null differ diff --git a/support/fonts/LICENSE-Roboto b/support/fonts/Roboto/LICENSE.txt similarity index 100% rename from support/fonts/LICENSE-Roboto rename to support/fonts/Roboto/LICENSE.txt diff --git a/support/fonts/Roboto-Black.ttf b/support/fonts/Roboto/Roboto-Black.ttf similarity index 100% rename from support/fonts/Roboto-Black.ttf rename to support/fonts/Roboto/Roboto-Black.ttf diff --git a/support/fonts/Roboto-BlackItalic.ttf b/support/fonts/Roboto/Roboto-BlackItalic.ttf similarity index 100% rename from support/fonts/Roboto-BlackItalic.ttf rename to support/fonts/Roboto/Roboto-BlackItalic.ttf diff --git a/support/fonts/Roboto-Bold.ttf b/support/fonts/Roboto/Roboto-Bold.ttf similarity index 100% rename from support/fonts/Roboto-Bold.ttf rename to support/fonts/Roboto/Roboto-Bold.ttf diff --git a/support/fonts/Roboto-BoldItalic.ttf b/support/fonts/Roboto/Roboto-BoldItalic.ttf similarity index 100% rename from support/fonts/Roboto-BoldItalic.ttf rename to support/fonts/Roboto/Roboto-BoldItalic.ttf diff --git a/support/fonts/Roboto-Italic.ttf b/support/fonts/Roboto/Roboto-Italic.ttf similarity index 100% rename from support/fonts/Roboto-Italic.ttf rename to support/fonts/Roboto/Roboto-Italic.ttf diff --git a/support/fonts/Roboto-Light.ttf b/support/fonts/Roboto/Roboto-Light.ttf similarity index 100% rename from support/fonts/Roboto-Light.ttf rename to support/fonts/Roboto/Roboto-Light.ttf diff --git a/support/fonts/Roboto-LightItalic.ttf b/support/fonts/Roboto/Roboto-LightItalic.ttf similarity index 100% rename from support/fonts/Roboto-LightItalic.ttf rename to support/fonts/Roboto/Roboto-LightItalic.ttf diff --git a/support/fonts/Roboto-Medium.ttf b/support/fonts/Roboto/Roboto-Medium.ttf similarity index 100% rename from support/fonts/Roboto-Medium.ttf rename to support/fonts/Roboto/Roboto-Medium.ttf diff --git a/support/fonts/Roboto-MediumItalic.ttf b/support/fonts/Roboto/Roboto-MediumItalic.ttf similarity index 100% rename from support/fonts/Roboto-MediumItalic.ttf rename to support/fonts/Roboto/Roboto-MediumItalic.ttf diff --git a/support/fonts/Roboto-Regular.ttf b/support/fonts/Roboto/Roboto-Regular.ttf similarity index 100% rename from support/fonts/Roboto-Regular.ttf rename to support/fonts/Roboto/Roboto-Regular.ttf diff --git a/support/fonts/Roboto-Thin.ttf b/support/fonts/Roboto/Roboto-Thin.ttf similarity index 100% rename from support/fonts/Roboto-Thin.ttf rename to support/fonts/Roboto/Roboto-Thin.ttf diff --git a/support/fonts/Roboto-ThinItalic.ttf b/support/fonts/Roboto/Roboto-ThinItalic.ttf similarity index 100% rename from support/fonts/Roboto-ThinItalic.ttf rename to support/fonts/Roboto/Roboto-ThinItalic.ttf diff --git a/support/fonts/SegoeUI/LICENSE.txt b/support/fonts/SegoeUI/LICENSE.txt new file mode 100644 index 00000000..2ca273a3 --- /dev/null +++ b/support/fonts/SegoeUI/LICENSE.txt @@ -0,0 +1 @@ +For the Segue-UI fonts on Linux see: https://github.com/mrbvrz/segoe-ui-linux diff --git a/support/fonts/SegoeUI/README b/support/fonts/SegoeUI/README new file mode 100644 index 00000000..e69de29b diff --git a/support/fonts/SegoeUI/segoeui.ttf b/support/fonts/SegoeUI/segoeui.ttf new file mode 100755 index 00000000..7db735b2 Binary files /dev/null and b/support/fonts/SegoeUI/segoeui.ttf differ diff --git a/support/fonts/SegoeUI/segoeuib.ttf b/support/fonts/SegoeUI/segoeuib.ttf new file mode 100755 index 00000000..82bf9853 Binary files /dev/null and b/support/fonts/SegoeUI/segoeuib.ttf differ diff --git a/support/fonts/SegoeUI/segoeuii.ttf b/support/fonts/SegoeUI/segoeuii.ttf new file mode 100755 index 00000000..418562f1 Binary files /dev/null and b/support/fonts/SegoeUI/segoeuii.ttf differ diff --git a/support/fonts/SegoeUI/segoeuil.ttf b/support/fonts/SegoeUI/segoeuil.ttf new file mode 100755 index 00000000..2bb02990 Binary files /dev/null and b/support/fonts/SegoeUI/segoeuil.ttf differ diff --git a/support/fonts/SegoeUI/segoeuisl.ttf b/support/fonts/SegoeUI/segoeuisl.ttf new file mode 100755 index 00000000..82af19cf Binary files /dev/null and b/support/fonts/SegoeUI/segoeuisl.ttf differ diff --git a/support/fonts/SegoeUI/segoeuiz.ttf b/support/fonts/SegoeUI/segoeuiz.ttf new file mode 100755 index 00000000..17b88720 Binary files /dev/null and b/support/fonts/SegoeUI/segoeuiz.ttf differ diff --git a/support/fonts/SegoeUI/seguibl.ttf b/support/fonts/SegoeUI/seguibl.ttf new file mode 100755 index 00000000..b2966570 Binary files /dev/null and b/support/fonts/SegoeUI/seguibl.ttf differ diff --git a/support/fonts/SegoeUI/seguibli.ttf b/support/fonts/SegoeUI/seguibli.ttf new file mode 100755 index 00000000..d38c82c8 Binary files /dev/null and b/support/fonts/SegoeUI/seguibli.ttf differ diff --git a/support/fonts/SegoeUI/seguiemj.ttf b/support/fonts/SegoeUI/seguiemj.ttf new file mode 100755 index 00000000..77497bf7 Binary files /dev/null and b/support/fonts/SegoeUI/seguiemj.ttf differ diff --git a/support/fonts/SegoeUI/seguihis.ttf b/support/fonts/SegoeUI/seguihis.ttf new file mode 100755 index 00000000..a10c573e Binary files /dev/null and b/support/fonts/SegoeUI/seguihis.ttf differ diff --git a/support/fonts/SegoeUI/seguili.ttf b/support/fonts/SegoeUI/seguili.ttf new file mode 100755 index 00000000..66a14495 Binary files /dev/null and b/support/fonts/SegoeUI/seguili.ttf differ diff --git a/support/fonts/SegoeUI/seguisb.ttf b/support/fonts/SegoeUI/seguisb.ttf new file mode 100755 index 00000000..3d90a5fc Binary files /dev/null and b/support/fonts/SegoeUI/seguisb.ttf differ diff --git a/support/fonts/SegoeUI/seguisbi.ttf b/support/fonts/SegoeUI/seguisbi.ttf new file mode 100755 index 00000000..99eee5bf Binary files /dev/null and b/support/fonts/SegoeUI/seguisbi.ttf differ diff --git a/support/fonts/SegoeUI/seguisli.ttf b/support/fonts/SegoeUI/seguisli.ttf new file mode 100755 index 00000000..bc6e5d91 Binary files /dev/null and b/support/fonts/SegoeUI/seguisli.ttf differ diff --git a/support/fonts/SegoeUI/seguisym.ttf b/support/fonts/SegoeUI/seguisym.ttf new file mode 100755 index 00000000..d987ce50 Binary files /dev/null and b/support/fonts/SegoeUI/seguisym.ttf differ