diff options
-rw-r--r-- | src/gui/text/qfontdatabase.cpp | 7 | ||||
-rw-r--r-- | src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm | 21 |
2 files changed, 28 insertions, 0 deletions
diff --git a/src/gui/text/qfontdatabase.cpp b/src/gui/text/qfontdatabase.cpp index bc7d379157..fe7dd80e44 100644 --- a/src/gui/text/qfontdatabase.cpp +++ b/src/gui/text/qfontdatabase.cpp @@ -793,6 +793,13 @@ QString qt_resolveFontFamilyAlias(const QString &alias) return alias; } +Q_GUI_EXPORT bool qt_isFontFamilyPopulated(const QString &familyName) +{ + QFontDatabasePrivate *d = privateDb(); + QtFontFamily *f = d->family(familyName, QFontDatabasePrivate::RequestFamily); + return f != nullptr && f->populated; +} + /*! Returns a list of alternative fonts for the specified \a family and \a style and \a script using the \a styleHint given. diff --git a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm index 047773d8e3..e8ea194897 100644 --- a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm +++ b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm @@ -454,6 +454,9 @@ static void addExtraFallbacks(QStringList *fallbackList) #endif } +// ### Replace this with QPlatformFontDatabase::isFamilyPopulated() in Qt 5.14 +Q_GUI_EXPORT extern bool qt_isFontFamilyPopulated(const QString &familyName); + QStringList QCoreTextFontDatabase::fallbacksForFamily(const QString &family, QFont::Style style, QFont::StyleHint styleHint, QChar::Script script) const { Q_UNUSED(style); @@ -481,7 +484,25 @@ QStringList QCoreTextFontDatabase::fallbacksForFamily(const QString &family, QFo fallbackList.append(QString::fromCFString(fallbackFamilyName)); } + // .Apple Symbols Fallback will be at the beginning of the list and we will + // detect that this has glyphs for Arabic and other writing systems. + // Since it is a symbol font, it should be the last resort, so that + // the proper fonts for these writing systems are preferred. + int symbolIndex = fallbackList.indexOf(QLatin1String(".Apple Symbols Fallback")); + if (symbolIndex >= 0) + fallbackList.move(symbolIndex, fallbackList.size() - 1); + addExtraFallbacks(&fallbackList); + + // Since iOS 13, the cascade list may contain meta-fonts which have not been + // populated to the database, such as ".AppleJapaneseFont". It is important that we + // include this in the fallback list, in order to get fallback support for all + // languages + for (const QString &fallback : fallbackList) { + if (!qt_isFontFamilyPopulated(fallback)) + const_cast<QCoreTextFontDatabase *>(this)->populateFamily(fallback); + } + extern QStringList qt_sort_families_by_writing_system(QChar::Script, const QStringList &); fallbackList = qt_sort_families_by_writing_system(script, fallbackList); |