Fix regression in handling Chinese system default font

Register font's english name as alias when populating font families.
This was incorrectly undone when support for subfamilies was added.

Task-number: QTBUG-57856
Change-Id: Ib71f905bb00db86d44fa0921ec56c8c76c332e06
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Liang Qi <liang.qi@qt.io>
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
This commit is contained in:
Allan Sandfeld Jensen 2017-01-05 11:28:45 +01:00 committed by Simon Hausmann
parent 04b095b24b
commit 7e3e5b2dcf
2 changed files with 22 additions and 4 deletions

View File

@ -1159,7 +1159,7 @@ void QWindowsFontDatabase::populateFamily(const QString &familyName)
ReleaseDC(0, dummy);
}
static int QT_WIN_CALLBACK populateFontFamilies(const LOGFONT *logFont, const TEXTMETRIC *,
static int QT_WIN_CALLBACK populateFontFamilies(const LOGFONT *logFont, const TEXTMETRIC *textmetric,
DWORD, LPARAM)
{
// the "@family" fonts are just the same as "family". Ignore them.
@ -1168,6 +1168,13 @@ static int QT_WIN_CALLBACK populateFontFamilies(const LOGFONT *logFont, const TE
if (faceNameW[0] && faceNameW[0] != L'@' && wcsncmp(faceNameW, L"WST_", 4)) {
const QString faceName = QString::fromWCharArray(faceNameW);
QPlatformFontDatabase::registerFontFamily(faceName);
// Register current font's english name as alias
const bool ttf = (textmetric->tmPitchAndFamily & TMPF_TRUETYPE);
if (ttf && qt_localizedName(faceName)) {
const QString englishName = qt_getEnglishName(faceName);
if (!englishName.isEmpty())
QPlatformFontDatabase::registerAliasToFontFamily(faceName, englishName);
}
}
return 1; // continue
}
@ -1183,7 +1190,9 @@ void QWindowsFontDatabase::populateFontDatabase()
EnumFontFamiliesEx(dummy, &lf, populateFontFamilies, 0, 0);
ReleaseDC(0, dummy);
// Work around EnumFontFamiliesEx() not listing the system font.
QPlatformFontDatabase::registerFontFamily(QWindowsFontDatabase::systemDefaultFont().family());
QString systemDefaultFamily = QWindowsFontDatabase::systemDefaultFont().family();
if (QPlatformFontDatabase::resolveFontFamilyAlias(systemDefaultFamily).isEmpty())
QPlatformFontDatabase::registerFontFamily(systemDefaultFamily);
}
typedef QSharedPointer<QWindowsFontEngineData> QWindowsFontEngineDataPtr;

View File

@ -362,8 +362,15 @@ static int QT_WIN_CALLBACK populateFontFamilies(const LOGFONT *logFont, const TE
if (!key && ttf && qt_localizedName(faceName))
key = findFontKey(qt_getEnglishName(faceName));
}
if (key)
if (key) {
QPlatformFontDatabase::registerFontFamily(faceName);
// Register current font's english name as alias
if (ttf && qt_localizedName(faceName)) {
const QString englishName = qt_getEnglishName(faceName);
if (!englishName.isEmpty())
QPlatformFontDatabase::registerAliasToFontFamily(faceName, englishName);
}
}
}
return 1; // continue
}
@ -378,7 +385,9 @@ void QWindowsFontDatabaseFT::populateFontDatabase()
EnumFontFamiliesEx(dummy, &lf, populateFontFamilies, 0, 0);
ReleaseDC(0, dummy);
// Work around EnumFontFamiliesEx() not listing the system font
QPlatformFontDatabase::registerFontFamily(QWindowsFontDatabase::systemDefaultFont().family());
QString systemDefaultFamily = QWindowsFontDatabase::systemDefaultFont().family();
if (QPlatformFontDatabase::resolveFontFamilyAlias(systemDefaultFamily).isEmpty())
QPlatformFontDatabase::registerFontFamily(systemDefaultFamily);
}
QFontEngine * QWindowsFontDatabaseFT::fontEngine(const QFontDef &fontDef, void *handle)