summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMÃ¥rten Nordheim <marten.nordheim@qt.io>2018-12-05 12:34:52 +0100
committerEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>2019-11-29 09:31:21 +0100
commitf881d00a4f37fcf244be8f93235b9c970aa1a9aa (patch)
treebda758f944478884fe47473b6d707f943848a827 /tests
parent00c869a5c605d7f82146c5a1d3f4f80ca706ca16 (diff)
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 <eskil.abrahamsen-blomfeldt@qt.io> Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/gui/text/qfontdatabase/testdata.qrc1
-rw-r--r--tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp29
-rw-r--r--tests/auto/shared/resources/testfont_open.otfbin0 -> 62676 bytes
3 files changed, 30 insertions, 0 deletions
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 @@
<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>
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"
diff --git a/tests/auto/shared/resources/testfont_open.otf b/tests/auto/shared/resources/testfont_open.otf
new file mode 100644
index 0000000000..0f7950f2dd
--- /dev/null
+++ b/tests/auto/shared/resources/testfont_open.otf
Binary files differ