From 95b49979fbf8956684ff41d5c1d72bff618a1957 Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Sun, 10 May 2020 19:05:43 +0400 Subject: [PATCH] Remove unneeded Segoe UI fallback struct and add Vazir file struct --- ui/style/style_core_font.cpp | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/ui/style/style_core_font.cpp b/ui/style/style_core_font.cpp index 3fad606..9c0efac 100644 --- a/ui/style/style_core_font.cpp +++ b/ui/style/style_core_font.cpp @@ -153,6 +153,14 @@ QString FontTypeNames[FontTypesCount] = { "DAOpenSansSemibold", "DAOpenSansSemiboldItalic", }; +QString FontTypePersianFallbackFiles[FontTypesCount] = { + "DAVazirRegular", + "DAVazirRegular", + "DAVazirMediumAsBold", + "DAVazirMediumAsBold", + "DAVazirMediumAsBold", + "DAVazirMediumAsBold", +}; QString FontTypePersianFallback[FontTypesCount] = { "DAVazirRegular", "DAVazirRegular", @@ -170,16 +178,6 @@ int32 FontTypeFlags[FontTypesCount] = { FontSemibold, FontSemibold | FontItalic, }; -#ifdef Q_OS_WIN -QString FontTypeWindowsFallback[FontTypesCount] = { - "Segoe UI", - "Segoe UI", - "Segoe UI", - "Segoe UI", - "Segoe UI", - "Segoe UI", -}; -#endif // Q_OS_WIN bool Started = false; QString Overrides[FontTypesCount]; @@ -200,10 +198,6 @@ void StartFonts() { } #ifndef DESKTOP_APP_USE_PACKAGED_FONTS - LoadCustomFont(":/gui/fonts/DAVazirRegular.ttf", "DAVazirRegular"); - LoadCustomFont(":/gui/fonts/DAVazirMediumAsBold.ttf", "DAVazirMedium", style::internal::FontBold); - LoadCustomFont(":/gui/fonts/DAVazirMediumAsBold.ttf", "DAVazirMedium", style::internal::FontSemibold); - bool areGood[FontTypesCount] = { false }; for (auto i = 0; i != FontTypesCount; ++i) { const auto file = FontTypeFiles[i]; @@ -212,12 +206,16 @@ void StartFonts() { areGood[i] = LoadCustomFont(":/gui/fonts/" + file + ".ttf", name, flags); Overrides[i] = name; + const auto persianFallbackFile = FontTypePersianFallbackFiles[i]; + const auto persianFallback = FontTypePersianFallback[i]; + LoadCustomFont(":/gui/fonts/" + persianFallbackFile + ".ttf", persianFallback, flags); + #ifdef Q_OS_WIN // Attempt to workaround a strange font bug with Open Sans Semibold not loading. // See https://github.com/telegramdesktop/tdesktop/issues/3276 for details. // Crash happens on "options.maxh / _t->_st->font->height" with "division by zero". // In that place "_t->_st->font" is "semiboldFont" is "font(13 "Open Sans Semibold"). - const auto fallback = FontTypeWindowsFallback[i]; + const auto fallback = "Segoe UI"; if (!areGood[i]) { if (ValidateFont(fallback, flags)) { Overrides[i] = fallback; @@ -230,7 +228,6 @@ void StartFonts() { //QFont::insertSubstitution(name, fallback); #endif // Q_OS_WIN - const auto persianFallback = FontTypePersianFallback[i]; QFont::insertSubstitution(name, persianFallback); }