diff options
author | Lars Knoll <lars.knoll@qt.io> | 2020-02-27 14:22:01 +0100 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2020-02-27 19:35:43 +0100 |
commit | bb802b4318e88e47d3f2c446bb9641f53efbaaed (patch) | |
tree | 57c49702d32a0b9ef4426bb0c1ec9a272dbcf94d /tests/auto/gui | |
parent | 924b97d6abf6f9935c9698984a1596c65324e3fa (diff) | |
parent | 5c6c0289f09d9bf18aaa35eed792e40840af5dce (diff) |
Merge "Merge remote-tracking branch 'origin/5.14' into 5.15"
Diffstat (limited to 'tests/auto/gui')
-rw-r--r-- | tests/auto/gui/text/qfontmetrics/tst_qfontmetrics.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/auto/gui/text/qfontmetrics/tst_qfontmetrics.cpp b/tests/auto/gui/text/qfontmetrics/tst_qfontmetrics.cpp index a0e8525268..6fe3e20083 100644 --- a/tests/auto/gui/text/qfontmetrics/tst_qfontmetrics.cpp +++ b/tests/auto/gui/text/qfontmetrics/tst_qfontmetrics.cpp @@ -59,6 +59,7 @@ private slots: void mnemonicTextWidth(); void leadingBelowLine(); void elidedMetrics(); + void zeroWidthMetrics(); }; void tst_QFontMetrics::same() @@ -358,5 +359,28 @@ void tst_QFontMetrics::elidedMetrics() QFontDatabase::removeApplicationFont(id); } +void tst_QFontMetrics::zeroWidthMetrics() +{ + QString zwnj(QChar(0x200c)); + QString zwsp(QChar(0x200b)); + + QFont font; + QFontMetricsF fm(font); + QCOMPARE(fm.horizontalAdvance(zwnj), 0); + QCOMPARE(fm.horizontalAdvance(zwsp), 0); + QCOMPARE(fm.boundingRect(zwnj).width(), 0); + QCOMPARE(fm.boundingRect(zwsp).width(), 0); + + QString string1 = QStringLiteral("(") + zwnj + QStringLiteral(")"); + QString string2 = QStringLiteral("(") + zwnj + zwnj + QStringLiteral(")"); + QString string3 = QStringLiteral("(") + zwsp + QStringLiteral(")"); + QString string4 = QStringLiteral("(") + zwsp + zwsp + QStringLiteral(")"); + + QCOMPARE(fm.horizontalAdvance(string1), fm.horizontalAdvance(string2)); + QCOMPARE(fm.horizontalAdvance(string3), fm.horizontalAdvance(string4)); + QCOMPARE(fm.boundingRect(string1).width(), fm.boundingRect(string2).width()); + QCOMPARE(fm.boundingRect(string3).width(), fm.boundingRect(string4).width()); +} + QTEST_MAIN(tst_QFontMetrics) #include "tst_qfontmetrics.moc" |