Remove unneeded Segoe UI fallback struct and add Vazir file struct

This commit is contained in:
Ilya Fedin 2020-05-10 19:05:43 +04:00 committed by John Preston
parent ef31d05da5
commit 95b49979fb

View file

@ -153,6 +153,14 @@ QString FontTypeNames[FontTypesCount] = {
"DAOpenSansSemibold", "DAOpenSansSemibold",
"DAOpenSansSemiboldItalic", "DAOpenSansSemiboldItalic",
}; };
QString FontTypePersianFallbackFiles[FontTypesCount] = {
"DAVazirRegular",
"DAVazirRegular",
"DAVazirMediumAsBold",
"DAVazirMediumAsBold",
"DAVazirMediumAsBold",
"DAVazirMediumAsBold",
};
QString FontTypePersianFallback[FontTypesCount] = { QString FontTypePersianFallback[FontTypesCount] = {
"DAVazirRegular", "DAVazirRegular",
"DAVazirRegular", "DAVazirRegular",
@ -170,16 +178,6 @@ int32 FontTypeFlags[FontTypesCount] = {
FontSemibold, FontSemibold,
FontSemibold | FontItalic, 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; bool Started = false;
QString Overrides[FontTypesCount]; QString Overrides[FontTypesCount];
@ -200,10 +198,6 @@ void StartFonts() {
} }
#ifndef DESKTOP_APP_USE_PACKAGED_FONTS #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 }; bool areGood[FontTypesCount] = { false };
for (auto i = 0; i != FontTypesCount; ++i) { for (auto i = 0; i != FontTypesCount; ++i) {
const auto file = FontTypeFiles[i]; const auto file = FontTypeFiles[i];
@ -212,12 +206,16 @@ void StartFonts() {
areGood[i] = LoadCustomFont(":/gui/fonts/" + file + ".ttf", name, flags); areGood[i] = LoadCustomFont(":/gui/fonts/" + file + ".ttf", name, flags);
Overrides[i] = name; Overrides[i] = name;
const auto persianFallbackFile = FontTypePersianFallbackFiles[i];
const auto persianFallback = FontTypePersianFallback[i];
LoadCustomFont(":/gui/fonts/" + persianFallbackFile + ".ttf", persianFallback, flags);
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
// Attempt to workaround a strange font bug with Open Sans Semibold not loading. // Attempt to workaround a strange font bug with Open Sans Semibold not loading.
// See https://github.com/telegramdesktop/tdesktop/issues/3276 for details. // See https://github.com/telegramdesktop/tdesktop/issues/3276 for details.
// Crash happens on "options.maxh / _t->_st->font->height" with "division by zero". // 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"). // 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 (!areGood[i]) {
if (ValidateFont(fallback, flags)) { if (ValidateFont(fallback, flags)) {
Overrides[i] = fallback; Overrides[i] = fallback;
@ -230,7 +228,6 @@ void StartFonts() {
//QFont::insertSubstitution(name, fallback); //QFont::insertSubstitution(name, fallback);
#endif // Q_OS_WIN #endif // Q_OS_WIN
const auto persianFallback = FontTypePersianFallback[i];
QFont::insertSubstitution(name, persianFallback); QFont::insertSubstitution(name, persianFallback);
} }