diff options
author | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> | 2021-12-01 09:14:23 +0100 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2021-12-02 10:24:53 +0000 |
commit | ec613a4649844e0eaa2a64444732eef7eeef2b81 (patch) | |
tree | 0fc0ab89b57bd17ba3b63cd45ea607529a4f2581 /tests | |
parent | 0945937c7c4617ea626a88dafbe2cf418dbffe19 (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.
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>
(cherry picked from commit 6b02473e1e4b559cb81c007a35a07746d843398c)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'tests')
-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 c78475a76f..9d6f1e0f7c 100644 --- a/tests/auto/gui/text/qfontmetrics/tst_qfontmetrics.cpp +++ b/tests/auto/gui/text/qfontmetrics/tst_qfontmetrics.cpp @@ -56,6 +56,8 @@ private slots: void leadingBelowLine(); void elidedMetrics(); void zeroWidthMetrics(); + void verticalMetrics_data(); + void verticalMetrics(); }; void tst_QFontMetrics::same() @@ -376,5 +378,22 @@ void tst_QFontMetrics::zeroWidthMetrics() QCOMPARE(fm.boundingRect(string3).width(), fm.boundingRect(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" |