iOS: Fix showing emoji characters

In d5abda313d, we started populating
meta-fallback-fonts in the font database because some that are
returned as fallbacks are not in the main list of fonts on the
system, so we would exclude them, thinking they were non-existent.

But populating these fonts by name does not always work, as
the system explicitly forbids requesting meta-fonts by name
for some cases. One of these was the emoji font, which would
resolve to a incompatible font descriptor and support for
emojis would be broken.

The fix is to retain the font descriptors we get from the
system instead, since these are guaranteed to be refer to the
correct font. This also saves us an unnecessary round-trip.

Task-number: QTBUG-78821
Task-number: QTBUG-77467
Change-Id: Icb17ccc75811eebf03919437828ba71f3ef08938
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
This commit is contained in:
Eskil Abrahamsen Blomfeldt 2019-10-02 08:46:21 +02:00
parent d3d5eadf24
commit c9eff4aa07

View File

@ -481,7 +481,12 @@ QStringList QCoreTextFontDatabase::fallbacksForFamily(const QString &family, QFo
for (int i = 0; i < numCascades; ++i) {
CTFontDescriptorRef fontFallback = (CTFontDescriptorRef) CFArrayGetValueAtIndex(cascadeList, i);
QCFString fallbackFamilyName = (CFStringRef) CTFontDescriptorCopyAttribute(fontFallback, kCTFontFamilyNameAttribute);
fallbackList.append(QString::fromCFString(fallbackFamilyName));
QString fallbackName = QString::fromCFString(fallbackFamilyName);
fallbackList.append(fallbackName);
if (!qt_isFontFamilyPopulated(fallbackName))
const_cast<QCoreTextFontDatabase *>(this)->populateFromDescriptor(fontFallback, fallbackName);
}
// .Apple Symbols Fallback will be at the beginning of the list and we will
@ -494,15 +499,6 @@ QStringList QCoreTextFontDatabase::fallbacksForFamily(const QString &family, QFo
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);