QWindowsFontDatabase: Check preferred family names for all fonts
The code was initially introduced in
9204b8c31e but getting the names were
conditioned on whether or not Windows identified it as a truetype font.
This excluded cases which had preferred names embedded but was not
truetype fonts. To fix that we run the code unconditionally.
[ChangeLog][Windows] Fixed a bug where some fonts would not be
accessible by referencing their typographic name.
Fixes: QTBUG-78556
Change-Id: I8823684b09cce3b1b8722b1e609a5bb49b13da13
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
bb10
parent
00c869a5c6
commit
f881d00a4f
|
|
@ -1069,18 +1069,16 @@ static bool addFontToDatabase(QString familyName,
|
|||
|
||||
QString subFamilyName;
|
||||
QString subFamilyStyle;
|
||||
if (ttf) {
|
||||
// Look-up names registered in the font
|
||||
QFontNames canonicalNames = qt_getCanonicalFontNames(logFont);
|
||||
if (qt_localizedName(familyName) && !canonicalNames.name.isEmpty())
|
||||
englishName = canonicalNames.name;
|
||||
if (!canonicalNames.preferredName.isEmpty()) {
|
||||
subFamilyName = familyName;
|
||||
subFamilyStyle = styleName;
|
||||
faceName = familyName; // Remember the original name for later lookups
|
||||
familyName = canonicalNames.preferredName;
|
||||
styleName = canonicalNames.preferredStyle;
|
||||
}
|
||||
// Look-up names registered in the font
|
||||
QFontNames canonicalNames = qt_getCanonicalFontNames(logFont);
|
||||
if (qt_localizedName(familyName) && !canonicalNames.name.isEmpty())
|
||||
englishName = canonicalNames.name;
|
||||
if (!canonicalNames.preferredName.isEmpty()) {
|
||||
subFamilyName = familyName;
|
||||
subFamilyStyle = styleName;
|
||||
faceName = familyName; // Remember the original name for later lookups
|
||||
familyName = canonicalNames.preferredName;
|
||||
styleName = canonicalNames.preferredStyle;
|
||||
}
|
||||
|
||||
QSupportedWritingSystems writingSystems;
|
||||
|
|
|
|||
|
|
@ -215,17 +215,15 @@ static bool addFontToDatabase(QString familyName,
|
|||
|
||||
QString subFamilyName;
|
||||
QString subFamilyStyle;
|
||||
if (ttf) {
|
||||
// Look-up names registered in the font
|
||||
QFontNames canonicalNames = qt_getCanonicalFontNames(logFont);
|
||||
if (qt_localizedName(familyName) && !canonicalNames.name.isEmpty())
|
||||
englishName = canonicalNames.name;
|
||||
if (!canonicalNames.preferredName.isEmpty()) {
|
||||
subFamilyName = familyName;
|
||||
subFamilyStyle = styleName;
|
||||
familyName = canonicalNames.preferredName;
|
||||
styleName = canonicalNames.preferredStyle;
|
||||
}
|
||||
// Look-up names registered in the font
|
||||
QFontNames canonicalNames = qt_getCanonicalFontNames(logFont);
|
||||
if (qt_localizedName(familyName) && !canonicalNames.name.isEmpty())
|
||||
englishName = canonicalNames.name;
|
||||
if (!canonicalNames.preferredName.isEmpty()) {
|
||||
subFamilyName = familyName;
|
||||
subFamilyStyle = styleName;
|
||||
familyName = canonicalNames.preferredName;
|
||||
styleName = canonicalNames.preferredStyle;
|
||||
}
|
||||
|
||||
QSupportedWritingSystems writingSystems;
|
||||
|
|
|
|||
|
|
@ -4,5 +4,6 @@
|
|||
<file alias="testfont.ttf">../../../shared/resources/testfont.ttf</file>
|
||||
<file alias="testfont_condensed.ttf">../../../shared/resources/testfont_condensed.ttf</file>
|
||||
<file alias="testfont_italic.ttf">../../../shared/resources/testfont_italic.ttf</file>
|
||||
<file alias="testfont_open.otf">../../../shared/resources/testfont_open.otf</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
|
|
|||
|
|
@ -76,6 +76,9 @@ private slots:
|
|||
void rasterFonts();
|
||||
void smoothFonts();
|
||||
|
||||
void registerOpenTypePreferredNamesSystem();
|
||||
void registerOpenTypePreferredNamesApplication();
|
||||
|
||||
private:
|
||||
QString m_ledFont;
|
||||
QString m_testFont;
|
||||
|
|
@ -440,5 +443,31 @@ void tst_QFontDatabase::smoothFonts()
|
|||
QVERIFY(!QFontDatabase().isBitmapScalable(font.family()));
|
||||
}
|
||||
|
||||
void tst_QFontDatabase::registerOpenTypePreferredNamesSystem()
|
||||
{
|
||||
QFontDatabase db;
|
||||
// This font family was picked because it was the only one I had installed which showcased the
|
||||
// problem
|
||||
if (!db.hasFamily(QString::fromLatin1("Source Code Pro ExtraLight")))
|
||||
QSKIP("Source Code Pro ExtraLight is not installed");
|
||||
|
||||
QStringList styles = db.styles(QString::fromLatin1("Source Code Pro"));
|
||||
QVERIFY(styles.contains(QLatin1String("ExtraLight")));
|
||||
}
|
||||
|
||||
void tst_QFontDatabase::registerOpenTypePreferredNamesApplication()
|
||||
{
|
||||
QFontDatabase db;
|
||||
|
||||
int id = QFontDatabase::addApplicationFont(QString::fromLatin1(":/testfont_open.otf"));
|
||||
if (id == -1)
|
||||
QSKIP("Skip the test since app fonts are not supported on this system");
|
||||
|
||||
QStringList styles = db.styles(QString::fromLatin1("QtBidiTestFont"));
|
||||
QVERIFY(styles.contains(QLatin1String("Open")));
|
||||
|
||||
QFontDatabase::removeApplicationFont(id);
|
||||
}
|
||||
|
||||
QTEST_MAIN(tst_QFontDatabase)
|
||||
#include "tst_qfontdatabase.moc"
|
||||
|
|
|
|||
Binary file not shown.
Loading…
Reference in New Issue