diff options
author | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> | 2018-01-08 13:29:38 +0100 |
---|---|---|
committer | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> | 2018-01-09 12:17:34 +0000 |
commit | 12687ccfd5a6056ab24a792dbe28f1d5829fd88c (patch) | |
tree | 7a6c7f249e201a4ac0b1760777b21d4936b76f84 /tests | |
parent | fcbaa8ec385e796c18cf317e8f364bd8e3c2538b (diff) |
CoreText: Order fallback fonts based on writing system support
After we stopped sanitizing the fallback font list (with change
6ca48a847a1805c3826004c5b989b4ae14397a37), we now need to make
sure it is ordered so that the fonts that support the writing
system in question are always tested first, otherwise we can end up
loading a lot of fonts that will never be used.
Task-number: QTBUG-65605
Change-Id: Id2a65bbff3e64e6d6e6b4f72500778ee3e811e84
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/gui/text/qrawfont/tst_qrawfont.cpp | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/auto/gui/text/qrawfont/tst_qrawfont.cpp b/tests/auto/gui/text/qrawfont/tst_qrawfont.cpp index ee775d4a31..37f94d0278 100644 --- a/tests/auto/gui/text/qrawfont/tst_qrawfont.cpp +++ b/tests/auto/gui/text/qrawfont/tst_qrawfont.cpp @@ -90,6 +90,9 @@ private slots: void rawFontFromInvalidData(); void kernedAdvances(); + + void fallbackFontsOrder(); + private: QString testFont; QString testFontBoldItalic; @@ -1009,6 +1012,38 @@ void tst_QRawFont::kernedAdvances() QVERIFY(FUZZY_LTEQ(qAbs(advances.at(0).x() - expectedAdvanceWidth), errorMargin)); } +void tst_QRawFont::fallbackFontsOrder() +{ + QFontDatabase fontDatabase; + int id = fontDatabase.addApplicationFont(testFont); + + QFont font("QtBidiTestFont"); + font.setPixelSize(12.0); + + QString arabicText = QFontDatabase::writingSystemSample(QFontDatabase::Arabic); + + // If this fails, then the writing system sample has changed and we need to create + // a new text containing both a space and Arabic characters. + QVERIFY(arabicText.contains(QLatin1Char(' '))); + + QTextLayout layout; + layout.setFont(font); + layout.setText(arabicText); + layout.setCacheEnabled(true); + layout.beginLayout(); + layout.createLine(); + layout.endLayout(); + + QList<QGlyphRun> glyphRuns = layout.glyphRuns(); + + // Since QtBidiTestFont does not support Arabic nor the space, both should map to + // the same font. If this fails, it is an indication that the list of fallbacks fonts + // is not sorted by writing system support. + QCOMPARE(glyphRuns.size(), 1); + + fontDatabase.removeApplicationFont(id); +} + #endif // QT_NO_RAWFONT QTEST_MAIN(tst_QRawFont) |