From a614bc6e39c8460ebe5b7a5aff546ca3219c8730 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Mon, 15 Sep 2014 12:14:17 +0200 Subject: [PATCH] Cocoa: Always add Arial Unicode MS to fallback list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The fallbacks on the platform should ideally contain all fonts that support the script passed in, but this would require populating the font database and checking the unicode ranges for all fonts, so it would cause a significant performance hit on Mac. What we do here instead is just return a set of default fonts as the fallbacks and disregard the requested script. The consequence of this is that some special unicode codepoints were not supported on Mac, because we weren't working with a full fallback list. To rectify this without breaking performance, we always add Arial Unicode MS to the end of the fallback list as a final fallback. This should always be present on the system and has a wide support of different scripts. [ChangeLog][OS X][Fonts] Fixed missing glyph box shown in place of some uncommon Unicode code points. Change-Id: I4fc8576bfddc8a73204aca2b16437d42c524bc79 Task-number: QTBUG-40986 Task-number: QTBUG-40549 Reviewed-by: Tor Arne Vestbø --- .../mac/qcoretextfontdatabase.mm | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm index a775f745fd6..c3553c79f9a 100644 --- a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm +++ b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm @@ -481,6 +481,17 @@ QStringList QCoreTextFontDatabase::fallbacksForFamily(const QString &family, QFo QCFString fallbackFamilyName = (CFStringRef) CTFontDescriptorCopyAttribute(fontFallback, kCTFontFamilyNameAttribute); fallbackList.append(QCFString::toQString(fallbackFamilyName)); } + +#if defined(Q_OS_OSX) + // Since we are only returning a list of default fonts for the current language, we do not + // cover all unicode completely. This was especially an issue for some of the common script + // symbols such as mathematical symbols, currency or geometric shapes. To minimize the risk + // of missing glyphs, we add Arial Unicode MS as a final fail safe, since this covers most + // of Unicode 2.1. + if (!fallbackList.contains(QStringLiteral("Arial Unicode MS"))) + fallbackList.append(QStringLiteral("Arial Unicode MS")); +#endif + fallbackLists[family] = fallbackList; } } @@ -524,6 +535,14 @@ QStringList QCoreTextFontDatabase::fallbacksForFamily(const QString &family, QFo if (QCoreTextFontEngine::supportsColorGlyphs()) fallbackList.append(QLatin1String("Apple Color Emoji")); + // Since we are only returning a list of default fonts for the current language, we do not + // cover all unicode completely. This was especially an issue for some of the common script + // symbols such as mathematical symbols, currency or geometric shapes. To minimize the risk + // of missing glyphs, we add Arial Unicode MS as a final fail safe, since this covers most + // of Unicode 2.1. + if (!fallbackList.contains(QStringLiteral("Arial Unicode MS"))) + fallbackList.append(QStringLiteral("Arial Unicode MS")); + fallbackLists[styleLookupKey.arg(fallbackStyleHint)] = fallbackList; } #else