From b619c35d8507eee3ad9b456128f811b561513727 Mon Sep 17 00:00:00 2001 From: Liang Qi Date: Mon, 28 Apr 2014 11:45:44 +0200 Subject: Revert "Mac: fix bugs for font selection in QFontDialog" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 3c09f6bc9aee0c97427fe8da6efdc73b4ac473aa. After fbaa6d3ca6fc2693c5c8a1cd8e565803adc97730, OS X/iOS no longer uses localized font names. Task-number: QTBUG-38548 Conflicts: src/gui/text/qfontdatabase.cpp Change-Id: Id7f7e1976e4ffc30c5c18cf57e2acb3aebafc301 Reviewed-by: Tor Arne Vestbø Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'src/plugins/platforms') diff --git a/src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm b/src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm index dc22da0983..a18f721e04 100644 --- a/src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm +++ b/src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm @@ -92,16 +92,20 @@ static QFont qfontForCocoaFont(NSFont *cocoaFont, const QFont &resolveFont) QFont newFont; if (cocoaFont) { int pSize = qRound([cocoaFont pointSize]); - 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)); + 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"); + } - newFont = QFontDatabase().font(family, style, pSize); + newFont = QFontDatabase().font(family, typeface, pSize); newFont.setUnderline(resolveFont.underline()); newFont.setStrikeOut(resolveFont.strikeOut()); - CFRelease(font); } return newFont; } -- cgit v1.2.3