diff options
author | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> | 2021-12-01 09:14:23 +0100 |
---|---|---|
committer | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> | 2021-12-02 07:54:39 +0100 |
commit | 6b02473e1e4b559cb81c007a35a07746d843398c (patch) | |
tree | d2ba614b3710c7d2e0320446f530335a58f99695 /tests/auto | |
parent | c6c039167cfdbc28351a73cc0819461c69bc0451 (diff) |
Fix overlapping text for Osaka font on macOS
The Osaka font on macOS has all zeroes in the OS/2 table, probably
because it is not intended to be cross-platform. In Qt 6 (since
f761ad3cd9ad1252f24b76ae413298dc7bed8af3) we are trying using the
same vertical metrics on all platforms, but this only works if
they are valid.
To work around this issue, we detect the case when ascent/descent
values are both 0, since this is very unlikely to be intentional,
so we fall back to the system-provided ascent and descent in these
cases.
Adding the test also revealed that we had missed the check for
a macOS-specific bitmap font format when skipping the check for
bitmap fonts in 7a18b7e2c2394b2b2cc95833c755f91193d9ba2e.
[ChangeLog][macOS][Text] Fixed a problem where using the Osaka
font would lead to overlapping text.
Pick-to: 6.2
Fixes: QTBUG-96880
Change-Id: Ifea7918641a68829e8f5ef20a4fb61c0a7e5b757
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/gui/text/qfontmetrics/tst_qfontmetrics.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/auto/gui/text/qfontmetrics/tst_qfontmetrics.cpp b/tests/auto/gui/text/qfontmetrics/tst_qfontmetrics.cpp index 9ed88fe8ed..f6700eb43a 100644 --- a/tests/auto/gui/text/qfontmetrics/tst_qfontmetrics.cpp +++ b/tests/auto/gui/text/qfontmetrics/tst_qfontmetrics.cpp @@ -57,6 +57,8 @@ private slots: void leadingBelowLine(); void elidedMetrics(); void zeroWidthMetrics(); + void verticalMetrics_data(); + void verticalMetrics(); }; void tst_QFontMetrics::same() @@ -394,5 +396,22 @@ void tst_QFontMetrics::zeroWidthMetrics() QCOMPARE(fm.tightBoundingRect(string3).width(), fm.tightBoundingRect(string4).width()); } +void tst_QFontMetrics::verticalMetrics_data() +{ + QTest::addColumn<QFont>("font"); + QStringList families = QFontDatabase::families(); + for (const QString &family : families) { + QFont font(family); + QTest::newRow(family.toUtf8()) << font; + } +} + +void tst_QFontMetrics::verticalMetrics() +{ + QFETCH(QFont, font); + QFontMetrics fm(font); + QVERIFY(fm.ascent() != 0 || fm.descent() != 0); +} + QTEST_MAIN(tst_QFontMetrics) #include "tst_qfontmetrics.moc" |