diff --git a/src/gui/text/coretext/qcoretextfontdatabase.mm b/src/gui/text/coretext/qcoretextfontdatabase.mm index e67a01fca9..a49f85e90c 100644 --- a/src/gui/text/coretext/qcoretextfontdatabase.mm +++ b/src/gui/text/coretext/qcoretextfontdatabase.mm @@ -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 attributes = CFDictionaryCreateMutable(kCFAllocatorDefault, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); - CFDictionaryAddValue(attributes, kCTFontFamilyNameAttribute, QCFString(familyName)); - QCFType nameOnlyDescriptor = CTFontDescriptorCreateWithAttributes(attributes); - - // A single family might match several different fonts with different styles eg. - QCFType 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 familyDescriptor = descriptorForFamily(familyName); + QCFType matchingFonts = CTFontDescriptorCreateMatchingFontDescriptors(familyDescriptor, nullptr); if (!matchingFonts) { qCWarning(lcQpaFonts) << "QCoreTextFontDatabase: Found no matching fonts for family" << familyName; return; @@ -429,18 +440,6 @@ template class QCoreTextFontDatabaseEngineFactory; template class QCoreTextFontDatabaseEngineFactory; #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 font = CTFontCreateWithFontDescriptor(descriptor, 0.0, nullptr);