summaryrefslogtreecommitdiffstats
path: root/src/gui/text
diff options
context:
space:
mode:
authorTor Arne Vestbø <tor.arne.vestbo@qt.io>2022-03-15 17:29:18 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2022-03-31 22:20:06 +0000
commitaa2da9e5b5444768e107154cdd744e685f39e905 (patch)
tree39373387ea1422be3379300d4be69bcf026b099c /src/gui/text
parent57d2d4310a86f0ecb1b0b7023b62f3b769345637 (diff)
CoreText: Reuse descriptorForFamily helper function in populateFamily
Change-Id: I2c1098309fc994fb7a131564679299a2e850870a Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> (cherry picked from commit 741a4987b8e2a11f515c463152037ae77cd1aea3) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src/gui/text')
-rw-r--r--src/gui/text/coretext/qcoretextfontdatabase.mm35
1 files changed, 17 insertions, 18 deletions
diff --git a/src/gui/text/coretext/qcoretextfontdatabase.mm b/src/gui/text/coretext/qcoretextfontdatabase.mm
index a032401720..8bfe21d58f 100644
--- a/src/gui/text/coretext/qcoretextfontdatabase.mm
+++ b/src/gui/text/coretext/qcoretextfontdatabase.mm
@@ -194,14 +194,25 @@ bool QCoreTextFontDatabase::populateFamilyAliases(const QString &missingFamily)
#endif
}
-void QCoreTextFontDatabase::populateFamily(const QString &familyName)
+CTFontDescriptorRef descriptorForFamily(const QString &familyName)
{
- QCFType<CFMutableDictionaryRef> attributes = CFDictionaryCreateMutable(kCFAllocatorDefault, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
- CFDictionaryAddValue(attributes, kCTFontFamilyNameAttribute, QCFString(familyName));
- QCFType<CTFontDescriptorRef> nameOnlyDescriptor = CTFontDescriptorCreateWithAttributes(attributes);
+ return CTFontDescriptorCreateWithAttributes(CFDictionaryRef(@{
+ (id)kCTFontFamilyNameAttribute: familyName.toNSString()
+ }));
+}
- // A single family might match several different fonts with different styles eg.
- QCFType<CFArrayRef> matchingFonts = (CFArrayRef) CTFontDescriptorCreateMatchingFontDescriptors(nameOnlyDescriptor, 0);
+CTFontDescriptorRef descriptorForFamily(const char *familyName)
+{
+ return descriptorForFamily(QString::fromLatin1(familyName));
+}
+
+void QCoreTextFontDatabase::populateFamily(const QString &familyName)
+{
+ // 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;
@@ -435,18 +446,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);