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>
This commit is contained in:
parent
a25ba47c2b
commit
43ea15d01c
@ -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();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user