summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@digia.com>2012-10-30 14:01:12 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2012-12-14 12:22:15 +0100
commit22929c5dfc98901a86a231a84dde90b19b94f8e5 (patch)
tree16194776af4361a66e3258216fb54902a315f68e /src/plugins/platforms
parente62ab752373086b58f351b14acdf98a8afffb515 (diff)
Mac: fix bugs for font selection in QFontDialog
Use localized family name and style name when selecting font with non-English locale Task-number: QTBUG-27415 Change-Id: Ie81507ed011fc096e0f5edad146e97c392e86494 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com> (cherry picked from commit 3c09f6bc9aee0c97427fe8da6efdc73b4ac473aa)
Diffstat (limited to 'src/plugins/platforms')
-rw-r--r--src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm16
1 files changed, 6 insertions, 10 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm b/src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm
index 5ccd019a9b..ff3ba63931 100644
--- a/src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm
+++ b/src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm
@@ -92,20 +92,16 @@ static QFont qfontForCocoaFont(NSFont *cocoaFont, const QFont &resolveFont)
QFont newFont;
if (cocoaFont) {
int pSize = qRound([cocoaFont pointSize]);
- QString family(QCFString::toQString([cocoaFont familyName]));
- QString typeface(QCFString::toQString([cocoaFont fontName]));
-
- int hyphenPos = typeface.indexOf(QLatin1Char('-'));
- if (hyphenPos != -1) {
- typeface.remove(0, hyphenPos + 1);
- } else {
- typeface = QLatin1String("Normal");
- }
+ CTFontDescriptorRef font = CTFontCopyFontDescriptor((CTFontRef)cocoaFont);
+ // QCoreTextFontDatabase::populateFontDatabase() is using localized names
+ QString family = QCFString::toQString((CFStringRef) CTFontDescriptorCopyLocalizedAttribute(font, kCTFontFamilyNameAttribute, NULL));
+ QString style = QCFString::toQString((CFStringRef) CTFontDescriptorCopyLocalizedAttribute(font, kCTFontStyleNameAttribute, NULL));
- newFont = QFontDatabase().font(family, typeface, pSize);
+ newFont = QFontDatabase().font(family, style, pSize);
newFont.setUnderline(resolveFont.underline());
newFont.setStrikeOut(resolveFont.strikeOut());
+ CFRelease(font);
}
return newFont;
}