summaryrefslogtreecommitdiffstats
path: root/tests
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-07 12:27:13 +0000
commitbeea7ba95bf3a3847a052321de555bbf5198ba84 (patch)
tree3f1664f757f49fda02a25784fa777b1fb39990ec /tests
parent13b09e1617dab776d91bfacabe614ce8a5ffaeff (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. Fixes: QTBUG-58995 Change-Id: I319e93e6b78c7c3c5539964ac5ab4e05f8902ab6 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> (cherry picked from commit 6f542f19bfe7bf3c0729f33d163841fbb6f169e7) Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Diffstat (limited to 'tests')
-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 d9beca35b5..7209a0139e 100644
--- a/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp
+++ b/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp
@@ -82,6 +82,10 @@ private slots:
void registerOpenTypePreferredNamesSystem();
void registerOpenTypePreferredNamesApplication();
+#ifdef Q_OS_WIN
+ void findCourier();
+#endif
+
private:
QString m_ledFont;
QString m_testFont;
@@ -476,5 +480,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"