summaryrefslogtreecommitdiffstats
path: root/tests/auto/qtextlayout
diff options
context:
space:
mode:
authorJiang Jiang <jiang.jiang@nokia.com>2010-12-10 15:07:25 (GMT)
committerJiang Jiang <jiang.jiang@nokia.com>2010-12-13 13:19:29 (GMT)
commit8e6078401562d40d2e63c4a2c769843088ec3350 (patch)
treecaba56a2f42ba36f924f4e0677561c12d0bec49d /tests/auto/qtextlayout
parent6902cd0d68c63e3a0d0dd1593a77f54c002ae363 (diff)
downloadQt-8e6078401562d40d2e63c4a2c769843088ec3350.zip
Qt-8e6078401562d40d2e63c4a2c769843088ec3350.tar.gz
Qt-8e6078401562d40d2e63c4a2c769843088ec3350.tar.bz2
Make sure num_glyphs pass to HarfBuzz is large enough
Currently we only pass the num_glyphs for the run to HB_ShapeItem, but it can be less then the string length for this run because of Unicode surrogates. Thus, we need to pass at least the length of that run as num_glyphs to HB (given that we have enough space allocated because for the entire string), if that's still not enough, we will do ensureSpace again according to the num_glyphs returned by HB and move remaining glyphs backwards. Task-number: QTBUG-15679 Reviewed-by: Lars Knoll
Diffstat (limited to 'tests/auto/qtextlayout')
-rw-r--r--tests/auto/qtextlayout/tst_qtextlayout.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/auto/qtextlayout/tst_qtextlayout.cpp b/tests/auto/qtextlayout/tst_qtextlayout.cpp
index dcc43d0..4f4413f 100644
--- a/tests/auto/qtextlayout/tst_qtextlayout.cpp
+++ b/tests/auto/qtextlayout/tst_qtextlayout.cpp
@@ -125,6 +125,7 @@ private slots:
void lineWidthFromBOM();
void textWidthVsWIdth();
+ void textWithSurrogates_qtbug15679();
private:
QFont testFont;
@@ -1412,6 +1413,24 @@ void tst_QTextLayout::textWidthVsWIdth()
}
}
+void tst_QTextLayout::textWithSurrogates_qtbug15679()
+{
+ QString str = QString::fromUtf8("🀀a🀀");
+ QTextLayout layout(str);
+ layout.beginLayout();
+ QTextLine line = layout.createLine();
+ layout.endLayout();
+
+ qreal x[6];
+ for (int i = 0; i < 6; i++)
+ x[i] = line.cursorToX(i);
+
+ // If the first and third character are using the same
+ // font, they must have the same advance (since they
+ // are surrogate pairs, we need to add two for each
+ // character)
+ QCOMPARE(x[2] - x[0], x[5] - x[3]);
+}
QTEST_MAIN(tst_QTextLayout)
#include "tst_qtextlayout.moc"