summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGabriel de Dietrich <gabriel.dedietrich@theqtcompany.com>2015-03-11 17:37:03 +0100
committerGabriel de Dietrich <gabriel.dedietrich@theqtcompany.com>2015-03-12 13:20:13 +0000
commitf85b6c246172c1d8998b592612fcaae43878a5c0 (patch)
treef02d680ea82e89c0ee281e4aed97fb35adf938c4 /src
parentc9aaa3e2cde5ffe5edaa4f17f84020d82609b7e9 (diff)
Get CoreText style name when resolving Qt font
Since we use CoreText API to populate the font DB, we should also make sure we use consistent data when doing queries. This partially reverts and ameds b619c35d8507eee. Change-Id: I6a3470fbee719ae1ea3085c252a4870040b9af1a Task-number: QTBUG-41487 Reviewed-by: Liang Qi <liang.qi@theqtcompany.com> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@theqtcompany.com>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm15
1 files changed, 4 insertions, 11 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm b/src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm
index 933034bb6f..d1802fe4f9 100644
--- a/src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm
+++ b/src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm
@@ -84,20 +84,13 @@ 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");
- }
+ QCFType<CTFontDescriptorRef> font(CTFontCopyFontDescriptor((CTFontRef)cocoaFont));
+ QString family(QCFString((CFStringRef)CTFontDescriptorCopyAttribute(font, kCTFontFamilyNameAttribute)));
+ QString style(QCFString(((CFStringRef)CTFontDescriptorCopyAttribute(font, kCTFontStyleNameAttribute))));
- newFont = QFontDatabase().font(family, typeface, pSize);
+ newFont = QFontDatabase().font(family, style, pSize);
newFont.setUnderline(resolveFont.underline());
newFont.setStrikeOut(resolveFont.strikeOut());
-
}
return newFont;
}