Revert "Mac: fix bugs for font selection in QFontDialog"

This reverts commit 3c09f6bc9a.

After fbaa6d3ca6, 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ø <tor.arne.vestbo@digia.com>
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>
This commit is contained in:
Liang Qi 2014-04-28 11:45:44 +02:00 committed by The Qt Project
parent 55e430a3b3
commit b619c35d85

View File

@ -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]));
newFont = QFontDatabase().font(family, style, pSize);
int hyphenPos = typeface.indexOf(QLatin1Char('-'));
if (hyphenPos != -1) {
typeface.remove(0, hyphenPos + 1);
} else {
typeface = QLatin1String("Normal");
}
newFont = QFontDatabase().font(family, typeface, pSize);
newFont.setUnderline(resolveFont.underline());
newFont.setStrikeOut(resolveFont.strikeOut());
CFRelease(font);
}
return newFont;
}