diff options
author | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> | 2023-01-25 08:16:27 +0100 |
---|---|---|
committer | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> | 2023-02-02 16:08:02 +0100 |
commit | 3b0ccbd8eccbd1fc21776a2f787d104f815b9d54 (patch) | |
tree | 33b2c6ed086e9a61679404a84334a307ba41e0c3 /tests/auto | |
parent | b7c63d2318f2536ab163070c92cdc8b14261a813 (diff) |
Update Harfbuzz to version 6.0.0
Note: This requires an update to the tst_qtextlayout test, because
the test assumed that the Arabic string would always yield a run
of two glyphs. This was a side effect of how Harfbuzz handled
Qt's test font, which has zero font tables and cannot be used for
shaping. With the Harfbuzz update, the Arabic text here yields a
single cluster instead, which actually makes more sense, so the
test has been made a bit more robust to support both cases.
Task-number: QTBUG-110338
Change-Id: I93d4cf8e3046dc93224e144d4c81d86bef4918d1
Reviewed-by: Lars Knoll <lars@knoll.priv.no>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit bfe080debbe764d341babfa37b471efb07575847)
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp | 41 |
1 files changed, 28 insertions, 13 deletions
diff --git a/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp b/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp index 32a0374fcd..6f234a3fcf 100644 --- a/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp +++ b/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp @@ -745,29 +745,29 @@ void tst_QTextLayout::cursorToXForBidiBoundaries_data() QTest::addColumn<Qt::LayoutDirection>("textDirection"); QTest::addColumn<QString>("text"); QTest::addColumn<int>("cursorPosition"); - QTest::addColumn<int>("expectedX"); + QTest::addColumn<int>("runsToInclude"); QTest::addRow("LTR, abcشزذabc, 0") << Qt::LeftToRight << "abcشزذabc" << 0 << 0; QTest::addRow("RTL, abcشزذabc, 9") << Qt::RightToLeft << "abcشزذabc" - << 9 << TESTFONT_SIZE * 3; + << 9 << 1; QTest::addRow("LTR, abcشزذabc, 3") << Qt::LeftToRight << "abcشزذabc" << 0 << 0; QTest::addRow("RTL, abcشزذabc, 6") << Qt::RightToLeft << "abcشزذabc" - << 9 << TESTFONT_SIZE * 3; + << 9 << 1; QTest::addRow("LTR, شزذabcشزذ, 0") << Qt::LeftToRight << "شزذabcشزذ" - << 0 << TESTFONT_SIZE * 2; + << 0 << 1; QTest::addRow("RTL, شزذabcشزذ, 9") << Qt::RightToLeft << "شزذabcشزذ" << 9 << 0; QTest::addRow("LTR, شزذabcشزذ, 3") << Qt::LeftToRight << "شزذabcشزذ" - << 3 << TESTFONT_SIZE * 2; + << 3 << 1; QTest::addRow("RTL, شزذabcشزذ, 3") << Qt::RightToLeft << "شزذabcشزذ" - << 3 << TESTFONT_SIZE * 5; + << 3 << 2; QTest::addRow("LTR, شزذabcشزذ, 6") << Qt::LeftToRight << "شزذabcشزذ" - << 6 << TESTFONT_SIZE * 5; + << 6 << 2; QTest::addRow("RTL, شزذabcشزذ, 6") << Qt::RightToLeft << "شزذabcشزذ" - << 6 << TESTFONT_SIZE * 2; + << 6 << 1; } void tst_QTextLayout::cursorToXForBidiBoundaries() @@ -775,7 +775,7 @@ void tst_QTextLayout::cursorToXForBidiBoundaries() QFETCH(Qt::LayoutDirection, textDirection); QFETCH(QString, text); QFETCH(int, cursorPosition); - QFETCH(int, expectedX); + QFETCH(int, runsToInclude); QTextOption option; option.setTextDirection(textDirection); @@ -784,12 +784,27 @@ void tst_QTextLayout::cursorToXForBidiBoundaries() layout.setTextOption(option); layout.beginLayout(); - QTextLine line = layout.createLine(); - line.setLineWidth(0x10000); + { + QTextLine line = layout.createLine(); + line.setLineWidth(0x10000); + } + layout.endLayout(); - QCOMPARE(line.cursorToX(cursorPosition), expectedX); + QTextLine line = layout.lineAt(0); + QList<QGlyphRun> glyphRuns = line.glyphRuns(); + QVERIFY(runsToInclude <= glyphRuns.size()); - layout.endLayout(); + std::sort(glyphRuns.begin(), glyphRuns.end(), + [](const QGlyphRun &first, const QGlyphRun &second) { + return first.positions().first().x() < second.positions().first().x(); + }); + + qreal expectedX = 0.0; + for (int i = 0; i < runsToInclude; ++i) { + expectedX += glyphRuns.at(i).boundingRect().width(); + } + + QCOMPARE(line.cursorToX(cursorPosition), expectedX); } void tst_QTextLayout::horizontalAlignment_data() |