From a0f145baab0080b335fa0a5be44472a3acda34e0 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Wed, 9 Oct 2019 17:37:11 +0200 Subject: Fix vertical advance for printing on macOS MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Y coordinate needed to be reversed to produce expected results. Fixes: QTBUG-69803 Change-Id: If349912cd078d17ce69d207c2ed35cf781c1a14d Reviewed-by: Michael Brüning --- src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/platformsupport/fontdatabases/mac') diff --git a/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm b/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm index 072dd1a28a..30c80ebd86 100644 --- a/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm +++ b/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm @@ -471,7 +471,7 @@ void QCoreTextFontEngine::draw(CGContextRef ctx, qreal x, qreal y, const QTextIt const qreal firstY = positions[0].y.toReal(); for (int i = 0; i < glyphs.size(); ++i) { cgPositions[i].x = positions[i].x.toReal() - firstX; - cgPositions[i].y = positions[i].y.toReal() - firstY; + cgPositions[i].y = firstY - positions[i].y.toReal(); cgGlyphs[i] = glyphs[i]; } -- cgit v1.2.3 From c9eff4aa074823cbfbfc5e0240ba53f7e9141367 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Wed, 2 Oct 2019 08:46:21 +0200 Subject: 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(-) (limited to 'src/platformsupport/fontdatabases/mac') 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); -- cgit v1.2.3 From 90d94c1c2c3571d48c7b8c2d6ba98ae4a9a28f0b Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Mon, 7 Oct 2019 08:39:35 +0200 Subject: macOS: Fix regression with some characters in non-bundle apps MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit .Noto Sans Univeral is a system-generated font, but for some undiscovered reason, it has different content when the app has a valid Info.plist versus when it does not. When there is no valid Info.plist, the font will act as a last-resort font and return a question mark glyph (index 4) for all characters it does not support. This was discovered with emojis, but I also verified that the font returns index 4 for a random character in the Cherokee range, in order to check if this was specific for emojis or not. This causes the font to take precedence over anything that follows it in the fallback list in apps that do not have a valid Info.plist, so it has to be at the end of the list. Note that in these apps, it will act as a last-resort font, so the glyphs returned for missing characters will be different from in a regular app bundle. But this seems safer than to exclude the font entirely, given that Noto Sans cover a large range of characters and might be needed. This font also refactors the look up of fonts to push to the end to avoid doing lots of unnecessary looping over the list. Fixes: QTBUG-78833 Change-Id: I38bec5d5941681c4b4586072f7811d31561e1051 Reviewed-by: Tor Arne Vestbø --- .../fontdatabases/mac/qcoretextfontdatabase.mm | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'src/platformsupport/fontdatabases/mac') diff --git a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm index e78fb4e8e4..c450e91d49 100644 --- a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm +++ b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm @@ -478,6 +478,9 @@ QStringList QCoreTextFontDatabase::fallbacksForFamily(const QString &family, QFo if (cascadeList) { QStringList fallbackList; const int numCascades = CFArrayGetCount(cascadeList); + + int symbolIndex = -1; + int notoSansUniversalIndex = -1; for (int i = 0; i < numCascades; ++i) { CTFontDescriptorRef fontFallback = (CTFontDescriptorRef) CFArrayGetValueAtIndex(cascadeList, i); QCFString fallbackFamilyName = (CFStringRef) CTFontDescriptorCopyAttribute(fontFallback, kCTFontFamilyNameAttribute); @@ -487,15 +490,28 @@ QStringList QCoreTextFontDatabase::fallbacksForFamily(const QString &family, QFo if (!qt_isFontFamilyPopulated(fallbackName)) const_cast(this)->populateFromDescriptor(fontFallback, fallbackName); + + if (fallbackName == QLatin1String(".Apple Symbols Fallback")) + symbolIndex = fallbackList.size() - 1; + else if (fallbackName == QLatin1String(".Noto Sans Universal")) + notoSansUniversalIndex = fallbackList.size() - 1; } // .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) + if (symbolIndex >= 0) { fallbackList.move(symbolIndex, fallbackList.size() - 1); + if (notoSansUniversalIndex > symbolIndex) + --notoSansUniversalIndex; + } + + // .Noto Sans Universal appears to have a bug when the application + // does not have a valid Info.plist, which causes it to return glyph #4 + // (a question mark) for any character. + if (notoSansUniversalIndex >= 0) + fallbackList.move(notoSansUniversalIndex, fallbackList.size() - 1); addExtraFallbacks(&fallbackList); -- cgit v1.2.3