From 35176fd02a67786ff0cdb9b9e5762f86b7c6c30e Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Tue, 21 Jan 2020 04:47:52 +0400 Subject: [PATCH] Add macro for disabling fonts bundling --- CMakeLists.txt | 5 ++++- ui/style/style_core_font.cpp | 8 ++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 81bf4d1..88c28e6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -33,7 +33,6 @@ PRIVATE ui/colors.palette emoji_suggestions/emoji_autocomplete.json - fonts/fonts.qrc qt_conf/mac.qrc qt_conf/win.qrc @@ -189,6 +188,10 @@ if (NOT DESKTOP_APP_USE_PACKAGED) nice_target_sources(lib_ui ${src_loc} PRIVATE qt_conf/linux.qrc) endif() +if (NOT DESKTOP_APP_USE_PACKAGED_FONTS) + nice_target_sources(lib_ui ${src_loc} PRIVATE fonts/fonts.qrc) +endif() + target_include_directories(lib_ui PUBLIC ${src_loc} diff --git a/ui/style/style_core_font.cpp b/ui/style/style_core_font.cpp index 9f3aad8..f8028da 100644 --- a/ui/style/style_core_font.cpp +++ b/ui/style/style_core_font.cpp @@ -15,7 +15,9 @@ #include void style_InitFontsResource() { +#ifndef DESKTOP_APP_USE_PACKAGED_FONTS Q_INIT_RESOURCE(fonts); +#endif // !DESKTOP_APP_USE_PACKAGED_FONTS #ifdef Q_OS_WIN Q_INIT_RESOURCE(win); #elif defined Q_OS_MAC // Q_OS_WIN @@ -93,6 +95,7 @@ enum { FontTypesCount, }; +#ifndef DESKTOP_APP_USE_PACKAGED_FONTS QString FontTypeNames[FontTypesCount] = { "DAOpenSansRegular", "DAOpenSansRegularItalic", @@ -101,6 +104,7 @@ QString FontTypeNames[FontTypesCount] = { "DAOpenSansSemibold", "DAOpenSansSemiboldItalic", }; +#endif // !DESKTOP_APP_USE_PACKAGED_FONTS int32 FontTypeFlags[FontTypesCount] = { 0, FontItalic, @@ -109,6 +113,7 @@ int32 FontTypeFlags[FontTypesCount] = { 0, FontItalic, }; +#ifdef Q_OS_WIN QString FontTypeWindowsFallback[FontTypesCount] = { "Segoe UI", "Segoe UI", @@ -117,6 +122,7 @@ QString FontTypeWindowsFallback[FontTypesCount] = { "Segoe UI Semibold", "Segoe UI Semibold", }; +#endif // Q_OS_WIN bool Started = false; QString Overrides[FontTypesCount]; @@ -131,6 +137,7 @@ void StartFonts() { style_InitFontsResource(); +#ifndef DESKTOP_APP_USE_PACKAGED_FONTS bool areGood[FontTypesCount] = { false }; for (auto i = 0; i != FontTypesCount; ++i) { const auto name = FontTypeNames[i]; @@ -155,6 +162,7 @@ void StartFonts() { //QFont::insertSubstitution(name, fallback); #endif // Q_OS_WIN } +#endif // !DESKTOP_APP_USE_PACKAGED_FONTS #ifdef Q_OS_MAC auto list = QStringList(); list.append(".SF NS Text");