Minimize amount of code to rebuild when switching options

This commit is contained in:
Ilya Fedin 2023-09-22 04:22:15 +04:00 committed by John Preston
parent a33bd4e0a5
commit 68b43db05d
3 changed files with 14 additions and 12 deletions

View file

@ -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)

View file

@ -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");

View file

@ -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(<glib.h>) // !DESKTOP_APP_USE_PACKAGED_FONTS
#elif __has_include(<glib.h>) // !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);