diff options
-rw-r--r-- | src/gui/text/qtextengine.cpp | 13 | ||||
-rw-r--r-- | tests/auto/gui/text/qglyphrun/tst_qglyphrun.cpp | 16 | ||||
-rw-r--r-- | tests/auto/shared/resources/test.ttf | bin | 2008 -> 2128 bytes |
3 files changed, 27 insertions, 2 deletions
diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp index f8ce0ba8af..28802c9bed 100644 --- a/src/gui/text/qtextengine.cpp +++ b/src/gui/text/qtextengine.cpp @@ -1546,12 +1546,21 @@ void QTextEngine::shapeText(int item) const si.num_glyphs = glyph_pos; } + if (Q_UNLIKELY(si.num_glyphs == 0)) { - Q_UNREACHABLE(); // ### report shaping errors somehow + if (Q_UNLIKELY(!ensureSpace(si.glyph_data_offset + 1))) { + qWarning() << "Unable to allocate space for place-holder glyph"; + return; + } + + si.num_glyphs = 1; + + // Overwrite with 0 token to indicate failure + QGlyphLayout g = availableGlyphs(&si); + g.glyphs[0] = 0; return; } - layoutData->used += si.num_glyphs; QGlyphLayout glyphs = shapedGlyphs(&si); diff --git a/tests/auto/gui/text/qglyphrun/tst_qglyphrun.cpp b/tests/auto/gui/text/qglyphrun/tst_qglyphrun.cpp index cf03877516..973a615d5e 100644 --- a/tests/auto/gui/text/qglyphrun/tst_qglyphrun.cpp +++ b/tests/auto/gui/text/qglyphrun/tst_qglyphrun.cpp @@ -63,6 +63,7 @@ private slots: void boundingRect(); void mixedScripts(); void multiLineBoundingRect(); + void defaultIgnorables(); private: int m_testFontId; @@ -631,6 +632,21 @@ void tst_QGlyphRun::multiLineBoundingRect() QVERIFY(firstLineGlyphRun.boundingRect().height() < allGlyphRun.boundingRect().height()); } +void tst_QGlyphRun::defaultIgnorables() +{ + QTextLayout layout; + layout.setFont(QFont("QtsSpecialTestFont")); + layout.setText(QChar(0x200D)); + layout.beginLayout(); + layout.createLine(); + layout.endLayout(); + + QList<QGlyphRun> runs = layout.glyphRuns(); + QCOMPARE(runs.size(), 1); + QCOMPARE(runs.at(0).glyphIndexes().size(), 1); + QCOMPARE(runs.at(0).glyphIndexes()[0], 0); +} + #endif // QT_NO_RAWFONT QTEST_MAIN(tst_QGlyphRun) diff --git a/tests/auto/shared/resources/test.ttf b/tests/auto/shared/resources/test.ttf Binary files differindex 382b2547b0..b2bb6cd036 100644 --- a/tests/auto/shared/resources/test.ttf +++ b/tests/auto/shared/resources/test.ttf |