diff options
author | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2018-05-03 18:40:29 +0200 |
---|---|---|
committer | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2018-05-04 15:49:11 +0000 |
commit | 43ea15d01cd491639d8cb5eb85da066f5d0a8571 (patch) | |
tree | 0005b160ae6e9bd7d2059c106c9125dd70b319d5 /src | |
parent | a25ba47c2b820117bdc60ba6bc772d6ea4093a4c (diff) |
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 <eskil.abrahamsen-blomfeldt@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm | 11 |
1 files changed, 5 insertions, 6 deletions
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<QFontEngineFT>::fontEngine(const { CTFontDescriptorRef descriptor = static_cast<CTFontDescriptorRef>(usrPtr); - if (NSURL *url = descriptorAttribute<NSURL>(descriptor, kCTFontURLAttribute)) { + if (NSValue *fontDataValue = descriptorAttribute<NSValue>(descriptor, (CFStringRef)kQtFontDataAttribute)) { + QByteArray *fontData = static_cast<QByteArray *>(fontDataValue.pointerValue); + return QFontEngineFT::create(*fontData, fontDef.pixelSize, + static_cast<QFont::HintingPreference>(fontDef.hintingPreference)); + } else if (NSURL *url = descriptorAttribute<NSURL>(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<NSValue>(descriptor, (CFStringRef)kQtFontDataAttribute)) { - QByteArray *fontData = static_cast<QByteArray *>(fontDataValue.pointerValue); - return QFontEngineFT::create(*fontData, fontDef.pixelSize, - static_cast<QFont::HintingPreference>(fontDef.hintingPreference)); } Q_UNREACHABLE(); } |