summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorMårten Nordheim <marten.nordheim@qt.io>2021-12-02 17:14:18 +0100
committerMårten Nordheim <marten.nordheim@qt.io>2021-12-06 20:06:06 +0100
commit6f542f19bfe7bf3c0729f33d163841fbb6f169e7 (patch)
tree8e952ae89fed338a7e52ba3410cfb5a1c1bd7f19 /tests/auto
parenteba9196304dcc9129a7bb68db87c6fb42c953090 (diff)
QFontDatabase (Windows): Sanitize font requests early
After the windows font engine was no longer marking everything as scalable we started limiting the font size of requests to the maximum of Courier when it was requested. This was a regression from 5.8 and not in agreement with our documentation. The problem is that we would only make the switch from Courier to Courier New after having already gone through the foundry-lookup and found a closest-available font size for Courier. With this sanitization step in the backend we can make these changes early enough that we haven't yet adjusted e.g. the font size. Pick-to: 6.2 5.15 Fixes: QTBUG-58995 Change-Id: I319e93e6b78c7c3c5539964ac5ab4e05f8902ab6 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp b/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp
index 6b6ad201bf..5a18260ffc 100644
--- a/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp
+++ b/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp
@@ -84,6 +84,10 @@ private slots:
void stretchRespected();
+#ifdef Q_OS_WIN
+ void findCourier();
+#endif
+
private:
QString m_ledFont;
QString m_testFont;
@@ -500,5 +504,32 @@ void tst_QFontDatabase::registerOpenTypePreferredNamesApplication()
QFontDatabase::removeApplicationFont(id);
}
+#ifdef Q_OS_WIN
+void tst_QFontDatabase::findCourier()
+{
+ QFont font = QFontDatabase::font(u"Courier"_qs, u""_qs, 16);
+ QFontInfo info(font);
+ QCOMPARE(info.family(), u"Courier New"_qs);
+ QCOMPARE(info.pointSize(), 16);
+
+ font = QFontDatabase::font("Courier", "", 64);
+ info = font;
+ QCOMPARE(info.family(), u"Courier New"_qs);
+ QCOMPARE(info.pointSize(), 64);
+
+ // By setting "PreferBitmap" we should get Courier itself.
+ font.setStyleStrategy(QFont::PreferBitmap);
+ info = font;
+ QCOMPARE(info.family(), u"Courier"_qs);
+ // Which has an upper bound on point size
+ QCOMPARE(info.pointSize(), 19);
+
+ font.setStyleStrategy(QFont::PreferDefault);
+ info = font;
+ QCOMPARE(info.family(), u"Courier New"_qs);
+ QCOMPARE(info.pointSize(), 64);
+}
+#endif
+
QTEST_MAIN(tst_QFontDatabase)
#include "tst_qfontdatabase.moc"