Add Vazir font for Persian glyphs

This commit is contained in:
Ilya Fedin 2020-05-07 17:51:40 +04:00 committed by John Preston
parent 0ef9558269
commit f987f596f1
5 changed files with 21 additions and 0 deletions

BIN
fonts/DAVazirBold.ttf Normal file

Binary file not shown.

BIN
fonts/DAVazirMedium.ttf Normal file

Binary file not shown.

BIN
fonts/DAVazirRegular.ttf Normal file

Binary file not shown.

View file

@ -6,6 +6,9 @@
<file>DAOpenSansBoldItalic.ttf</file> <file>DAOpenSansBoldItalic.ttf</file>
<file>DAOpenSansSemibold.ttf</file> <file>DAOpenSansSemibold.ttf</file>
<file>DAOpenSansSemiboldItalic.ttf</file> <file>DAOpenSansSemiboldItalic.ttf</file>
<file>DAVazirRegular.ttf</file>
<file>DAVazirBold.ttf</file>
<file>DAVazirMedium.ttf</file>
</qresource> </qresource>
<qresource prefix="/fc"> <qresource prefix="/fc">
<file>fc-custom.conf</file> <file>fc-custom.conf</file>

View file

@ -145,6 +145,14 @@ QString FontTypeNames[FontTypesCount] = {
"DAOpenSansSemibold", "DAOpenSansSemibold",
"DAOpenSansSemiboldItalic", "DAOpenSansSemiboldItalic",
}; };
QString FontTypePersianFallback[FontTypesCount] = {
"DAVazirRegular",
"DAVazirRegular",
"DAVazirBold",
"DAVazirBold",
"DAVazirMedium",
"DAVazirMedium",
};
#endif // !DESKTOP_APP_USE_PACKAGED_FONTS #endif // !DESKTOP_APP_USE_PACKAGED_FONTS
int32 FontTypeFlags[FontTypesCount] = { int32 FontTypeFlags[FontTypesCount] = {
0, 0,
@ -184,12 +192,17 @@ void StartFonts() {
} }
#ifndef DESKTOP_APP_USE_PACKAGED_FONTS #ifndef DESKTOP_APP_USE_PACKAGED_FONTS
LoadCustomFont(":/gui/fonts/DAVazirRegular.ttf", "DAVazirRegular");
LoadCustomFont(":/gui/fonts/DAVazirBold.ttf", "DAVazirBold", style::internal::FontBold);
LoadCustomFont(":/gui/fonts/DAVazirMedium.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 name = FontTypeNames[i]; const auto name = FontTypeNames[i];
const auto flags = FontTypeFlags[i]; const auto flags = FontTypeFlags[i];
areGood[i] = LoadCustomFont(":/gui/fonts/" + name + ".ttf", name, flags); areGood[i] = LoadCustomFont(":/gui/fonts/" + name + ".ttf", name, flags);
Overrides[i] = name; Overrides[i] = name;
#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.
@ -207,6 +220,11 @@ void StartFonts() {
// //
//QFont::insertSubstitution(name, fallback); //QFont::insertSubstitution(name, fallback);
#endif // Q_OS_WIN #endif // Q_OS_WIN
#if defined Q_OS_WIN || defined Q_OS_LINUX
const auto persianFallback = FontTypePersianFallback[i];
QFont::insertSubstitution(name, persianFallback);
#endif // Q_OS_WIN || Q_OS_LINUX
} }
#ifdef Q_OS_MAC #ifdef Q_OS_MAC