From f881d00a4f37fcf244be8f93235b9c970aa1a9aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= Date: Wed, 5 Dec 2018 12:34:52 +0100 Subject: QWindowsFontDatabase: Check preferred family names for all fonts The code was initially introduced in 9204b8c31ea1b5f0c05870c5b5d74c33b1a4f622 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 Reviewed-by: Allan Sandfeld Jensen --- tests/auto/gui/text/qfontdatabase/testdata.qrc | 1 + .../gui/text/qfontdatabase/tst_qfontdatabase.cpp | 29 ++++++++++++++++++++++ 2 files changed, 30 insertions(+) (limited to 'tests/auto/gui/text') diff --git a/tests/auto/gui/text/qfontdatabase/testdata.qrc b/tests/auto/gui/text/qfontdatabase/testdata.qrc index 224e845601..a590099b20 100644 --- a/tests/auto/gui/text/qfontdatabase/testdata.qrc +++ b/tests/auto/gui/text/qfontdatabase/testdata.qrc @@ -4,5 +4,6 @@ ../../../shared/resources/testfont.ttf ../../../shared/resources/testfont_condensed.ttf ../../../shared/resources/testfont_italic.ttf + ../../../shared/resources/testfont_open.otf diff --git a/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp b/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp index 2b69801b59..12e8083622 100644 --- a/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp +++ b/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp @@ -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" -- cgit v1.2.3