diff options
author | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> | 2022-11-28 14:24:45 +0100 |
---|---|---|
committer | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> | 2022-12-05 07:55:43 +0100 |
commit | c9d991de1ff32a7993aae90b50badfaa39323a61 (patch) | |
tree | ad32af2c54b937480c3d9009cb982164510ec792 /tests/auto/gui/text/qglyphrun/tst_qglyphrun.cpp | |
parent | 64847a3930a1d29dfec47dc6fd084f42deeced20 (diff) |
Fix missing text when Harfbuzz fails to shape a substring
This amends fccd419dd632306a4bd85928223e0a56a59510ef.
If Harfbuzz failed on one of the items in a string and returned
zero glyphs, then we would exit the shaping loop. The mentioned
change fixed a crash related to this when the ignored character
was the only character in the string, but it occurred in a
subitem of a longer string, then we would return and fail to
lay out the rest of the string.
This popped up recently because an update to Harfbuzz has caused
it to return zero glyphs when applying the Apple emoji font to
an isolated variant character (see bug report). When we matched
the symbol to the main font and only the variant character to
the emoji font, we would get in this situation, and end up
exiting the shaping early.
[ChangeLog][QtGui][Text] Fixed a regression which would
sometimes cause text to disappear if the string contained
an unmatched variation selector character.
Pick-to: 6.4
Fixes: QTBUG-108799
Change-Id: I616ab1b2d33c2df731419c5ce06fbc578a625a32
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'tests/auto/gui/text/qglyphrun/tst_qglyphrun.cpp')
-rw-r--r-- | tests/auto/gui/text/qglyphrun/tst_qglyphrun.cpp | 40 |
1 files changed, 32 insertions, 8 deletions
diff --git a/tests/auto/gui/text/qglyphrun/tst_qglyphrun.cpp b/tests/auto/gui/text/qglyphrun/tst_qglyphrun.cpp index 8275b1f427..b0d6efc065 100644 --- a/tests/auto/gui/text/qglyphrun/tst_qglyphrun.cpp +++ b/tests/auto/gui/text/qglyphrun/tst_qglyphrun.cpp @@ -608,15 +608,39 @@ void tst_QGlyphRun::multiLineBoundingRect() void tst_QGlyphRun::defaultIgnorables() { - QTextLayout layout; - layout.setFont(QFont("QtsSpecialTestFont")); - layout.setText(QChar(0x200D)); - layout.beginLayout(); - layout.createLine(); - layout.endLayout(); + { + QTextLayout layout; + layout.setFont(QFont("QtsSpecialTestFont")); + layout.setText(QChar(0x200D)); + layout.beginLayout(); + layout.createLine(); + layout.endLayout(); + + QList<QGlyphRun> runs = layout.glyphRuns(); + QCOMPARE(runs.size(), 0); + } + + { + QTextLayout layout; + layout.setFont(QFont("QtsSpecialTestFont")); + layout.setText(QStringLiteral("AAA") + QChar(0xFE0F) + QStringLiteral("111")); + layout.beginLayout(); + layout.createLine(); + layout.endLayout(); + + QList<QGlyphRun> runs = layout.glyphRuns(); + QVERIFY(!runs.isEmpty()); - QList<QGlyphRun> runs = layout.glyphRuns(); - QCOMPARE(runs.size(), 0); + bool hasFullMainFontRun = false; + for (const QGlyphRun &run : runs) { + if (run.rawFont().familyName() == QStringLiteral("QtsSpecialTestFont") + && run.glyphIndexes().size() == 6) { + hasFullMainFontRun = true; + break; + } + } + QVERIFY(hasFullMainFontRun); + } } void tst_QGlyphRun::stringIndexes() |