diff options
authorTor Arne Vestbø <>2014-04-30 14:50:46 +0200
committerThe Qt Project <>2014-05-12 13:44:51 +0200
commita669564597f1d9aebe6f992d890b730c7be10f6f (patch)
parent6c42ddf31f5b502a1189a7b6eb6de33775b95e94 (diff)
Allow QFont lookups using localized family names by adding family alias
After fbaa6d3ca6fc269 QFont family names are non-localized on iOS/OS X, which means applications that try to initialize QFont with a localized family name (explicitly, or from user input), will fail, and get the fallback font instead. We now add font family aliases for the localized family names, so that font matching will work even for localized family names. Note that QFontDatabase::families() still returns a non-localized list. Task-number: QTBUG-38628 Change-Id: Id351befa69916ce162c939733bbfcc774f075120 Reviewed-by: Eskil Abrahamsen Blomfeldt <>
1 files changed, 8 insertions, 1 deletions
diff --git a/src/platformsupport/fontdatabases/mac/ b/src/platformsupport/fontdatabases/mac/
index 1c0e888758..9248785696 100644
--- a/src/platformsupport/fontdatabases/mac/
+++ b/src/platformsupport/fontdatabases/mac/
@@ -196,13 +196,20 @@ void QCoreTextFontDatabase::populateFontDatabase()
QCFType<CFArrayRef> familyNames = availableFamilyNames();
const int numberOfFamilies = CFArrayGetCount(familyNames);
for (int i = 0; i < numberOfFamilies; ++i) {
- QString familyName = QCFString::toQString((CFStringRef) CFArrayGetValueAtIndex(familyNames, i));
+ CFStringRef familyNameRef = (CFStringRef) CFArrayGetValueAtIndex(familyNames, i);
+ QString familyName = QCFString::toQString(familyNameRef);
// Don't populate internal fonts
if (familyName.startsWith(QLatin1Char('.')) || familyName == QStringLiteral("LastResort"))
+#if defined(Q_OS_OSX)
+ QString localizedFamilyName = QString::fromNSString([[NSFontManager sharedFontManager] localizedNameForFamily:(NSString*)familyNameRef face:nil]);
+ if (familyName != localizedFamilyName)
+ QPlatformFontDatabase::registerAliasToFontFamily(familyName, localizedFamilyName);