CoreText: Reuse descriptorForFamily helper function in populateFamily
Pick-to: 6.2 6.3 Change-Id: I2c1098309fc994fb7a131564679299a2e850870a Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>bb10
parent
1ab928c7f6
commit
741a4987b8
|
|
@ -188,14 +188,25 @@ bool QCoreTextFontDatabase::populateFamilyAliases(const QString &missingFamily)
|
|||
#endif
|
||||
}
|
||||
|
||||
CTFontDescriptorRef descriptorForFamily(const QString &familyName)
|
||||
{
|
||||
return CTFontDescriptorCreateWithAttributes(CFDictionaryRef(@{
|
||||
(id)kCTFontFamilyNameAttribute: familyName.toNSString()
|
||||
}));
|
||||
}
|
||||
|
||||
CTFontDescriptorRef descriptorForFamily(const char *familyName)
|
||||
{
|
||||
return descriptorForFamily(QString::fromLatin1(familyName));
|
||||
}
|
||||
|
||||
void QCoreTextFontDatabase::populateFamily(const QString &familyName)
|
||||
{
|
||||
QCFType<CFMutableDictionaryRef> attributes = CFDictionaryCreateMutable(kCFAllocatorDefault, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
|
||||
CFDictionaryAddValue(attributes, kCTFontFamilyNameAttribute, QCFString(familyName));
|
||||
QCFType<CTFontDescriptorRef> nameOnlyDescriptor = CTFontDescriptorCreateWithAttributes(attributes);
|
||||
|
||||
// A single family might match several different fonts with different styles eg.
|
||||
QCFType<CFArrayRef> matchingFonts = (CFArrayRef) CTFontDescriptorCreateMatchingFontDescriptors(nameOnlyDescriptor, 0);
|
||||
// A single family might match several different fonts with different styles.
|
||||
// We need to add them all so that the font database has the full picture,
|
||||
// as once a family has been populated we will not populate it again.
|
||||
QCFType<CTFontDescriptorRef> familyDescriptor = descriptorForFamily(familyName);
|
||||
QCFType<CFArrayRef> matchingFonts = CTFontDescriptorCreateMatchingFontDescriptors(familyDescriptor, nullptr);
|
||||
if (!matchingFonts) {
|
||||
qCWarning(lcQpaFonts) << "QCoreTextFontDatabase: Found no matching fonts for family" << familyName;
|
||||
return;
|
||||
|
|
@ -429,18 +440,6 @@ template class QCoreTextFontDatabaseEngineFactory<QCoreTextFontEngine>;
|
|||
template class QCoreTextFontDatabaseEngineFactory<QFontEngineFT>;
|
||||
#endif
|
||||
|
||||
CTFontDescriptorRef descriptorForFamily(const QString &familyName)
|
||||
{
|
||||
return CTFontDescriptorCreateWithAttributes(CFDictionaryRef(@{
|
||||
(id)kCTFontFamilyNameAttribute: familyName.toNSString()
|
||||
}));
|
||||
}
|
||||
|
||||
CTFontDescriptorRef descriptorForFamily(const char *familyName)
|
||||
{
|
||||
return descriptorForFamily(QString::fromLatin1(familyName));
|
||||
}
|
||||
|
||||
CFArrayRef fallbacksForDescriptor(CTFontDescriptorRef descriptor)
|
||||
{
|
||||
QCFType<CTFontRef> font = CTFontCreateWithFontDescriptor(descriptor, 0.0, nullptr);
|
||||
|
|
|
|||
Loading…
Reference in New Issue