diff --git a/CMakeLists.txt b/CMakeLists.txt index 3323a52..9038739 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -33,6 +33,7 @@ PRIVATE ui/colors.palette emoji_suggestions/emoji_autocomplete.json + fonts/fonts.qrc qt_conf/win.qrc ui/dpr/dpr_icon.cpp @@ -298,8 +299,9 @@ PRIVATE emoji_suggestions/emoji_suggestions_helper.h ) -if (NOT DESKTOP_APP_USE_PACKAGED_FONTS) - nice_target_sources(lib_ui ${src_loc} PRIVATE fonts/fonts.qrc) +if (DESKTOP_APP_USE_PACKAGED_FONTS) + target_compile_definitions(lib_ui PRIVATE LIB_UI_USE_PACKAGED_FONTS) + remove_target_sources(lib_ui ${src_loc} fonts/fonts.qrc) endif() if (WIN32) diff --git a/ui/style/style_core_custom_font.cpp b/ui/style/style_core_custom_font.cpp index 8f42baf..0ad0fdf 100644 --- a/ui/style/style_core_custom_font.cpp +++ b/ui/style/style_core_custom_font.cpp @@ -52,11 +52,11 @@ QFont ResolveFont(const QString &familyOverride, uint32 flags, int size) { } else { result.setFamily(GetFontOverride(flags)); if (bold) { -#ifdef DESKTOP_APP_USE_PACKAGED_FONTS +#ifdef LIB_UI_USE_PACKAGED_FONTS result.setWeight(QFont::DemiBold); -#else // DESKTOP_APP_USE_PACKAGED_FONTS +#else // LIB_UI_USE_PACKAGED_FONTS result.setBold(true); -#endif // !DESKTOP_APP_USE_PACKAGED_FONTS +#endif // !LIB_UI_USE_PACKAGED_FONTS if (flags & FontItalic) { result.setStyleName("Semibold Italic"); diff --git a/ui/style/style_core_font.cpp b/ui/style/style_core_font.cpp index 4ed7089..8e067ca 100644 --- a/ui/style/style_core_font.cpp +++ b/ui/style/style_core_font.cpp @@ -29,9 +29,9 @@ void style_InitFontsResource() { #else // Q_OS_MAC -#ifndef DESKTOP_APP_USE_PACKAGED_FONTS +#ifndef LIB_UI_USE_PACKAGED_FONTS Q_INIT_RESOURCE(fonts); -#endif // !DESKTOP_APP_USE_PACKAGED_FONTS +#endif // !LIB_UI_USE_PACKAGED_FONTS #ifdef Q_OS_WIN Q_INIT_RESOURCE(win); #endif // Q_OS_WIN @@ -127,7 +127,7 @@ enum { FontTypesCount, }; -#ifndef DESKTOP_APP_USE_PACKAGED_FONTS +#ifndef LIB_UI_USE_PACKAGED_FONTS QString FontTypeFiles[FontTypesCount] = { "DAOpenSansRegular", "DAOpenSansRegularItalic", @@ -160,7 +160,7 @@ QString FontTypePersianFallback[FontTypesCount] = { "DAVazirMedium", "DAVazirMedium", }; -#endif // !DESKTOP_APP_USE_PACKAGED_FONTS +#endif // !LIB_UI_USE_PACKAGED_FONTS int32 FontTypeFlags[FontTypesCount] = { 0, FontItalic, @@ -183,7 +183,7 @@ void StartFonts() { style_InitFontsResource(); -#ifndef DESKTOP_APP_USE_PACKAGED_FONTS +#ifndef LIB_UI_USE_PACKAGED_FONTS [[maybe_unused]] bool areGood[FontTypesCount] = { false }; for (auto i = 0; i != FontTypesCount; ++i) { const auto file = FontTypeFiles[i]; @@ -227,11 +227,11 @@ void StartFonts() { QFont::insertSubstitutions(name, list); } #endif // Q_OS_MAC -#elif __has_include() // !DESKTOP_APP_USE_PACKAGED_FONTS +#elif __has_include() // !LIB_UI_USE_PACKAGED_FONTS g_warning( "Unable to load patched fonts with Qt workarounds, " "expect font issues."); -#endif // DESKTOP_APP_USE_PACKAGED_FONTS +#endif // LIB_UI_USE_PACKAGED_FONTS auto appFont = QApplication::font(); appFont.setStyleStrategy(QFont::PreferQuality);