From 43ea15d01cd491639d8cb5eb85da066f5d0a8571 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Thu, 3 May 2018 18:40:29 +0200 Subject: macOS + FreeType: Properly distinguish memory fonts from file fonts In recent macOS versions the descriptor created from the function CTFontManagerCreateFontDescriptorFromData() will contain the NSCTFontFileURLAttribute with a value such as: file://iNmEmOrYcGfOnT_0x101d3c3a0#postscript-name=New Which means we can't use the presence of the kCTFontURLAttribute to determine that we're dealing with a file font. Instead we check for our custom kQtFontDataAttribute first, which is only set for memory fonts. Task-number: QTBUG-68044 Change-Id: Ie87d06b5a9e0e251305200b717f18ef68ccc6abc Reviewed-by: Eskil Abrahamsen Blomfeldt --- .../fontdatabases/mac/qcoretextfontdatabase.mm | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm index f31f58945b..91c2dc8cf0 100644 --- a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm +++ b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm @@ -451,16 +451,15 @@ QFontEngine *QCoreTextFontDatabaseEngineFactory::fontEngine(const { CTFontDescriptorRef descriptor = static_cast(usrPtr); - if (NSURL *url = descriptorAttribute(descriptor, kCTFontURLAttribute)) { + if (NSValue *fontDataValue = descriptorAttribute(descriptor, (CFStringRef)kQtFontDataAttribute)) { + QByteArray *fontData = static_cast(fontDataValue.pointerValue); + return QFontEngineFT::create(*fontData, fontDef.pixelSize, + static_cast(fontDef.hintingPreference)); + } else if (NSURL *url = descriptorAttribute(descriptor, kCTFontURLAttribute)) { Q_ASSERT(url.fileURL); QFontEngine::FaceId faceId; faceId.filename = QString::fromNSString(url.path).toUtf8(); return QFontEngineFT::create(fontDef, faceId); - - } else if (NSValue *fontDataValue = descriptorAttribute(descriptor, (CFStringRef)kQtFontDataAttribute)) { - QByteArray *fontData = static_cast(fontDataValue.pointerValue); - return QFontEngineFT::create(*fontData, fontDef.pixelSize, - static_cast(fontDef.hintingPreference)); } Q_UNREACHABLE(); } -- cgit v1.2.3