From c9eff4aa074823cbfbfc5e0240ba53f7e9141367 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Wed, 2 Oct 2019 08:46:21 +0200 Subject: [PATCH] iOS: Fix showing emoji characters MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In d5abda313dab0f83873d34b7c4ddbe8d8a06dacf, 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ø --- .../fontdatabases/mac/qcoretextfontdatabase.mm | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm index e8ea194897..e78fb4e8e4 100644 --- a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm +++ b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm @@ -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(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(this)->populateFamily(fallback); - } - extern QStringList qt_sort_families_by_writing_system(QChar::Script, const QStringList &); fallbackList = qt_sort_families_by_writing_system(script, fallbackList);