diff options
author | Jiang Jiang <jiang.jiang@nokia.com> | 2011-05-19 10:40:03 (GMT) |
---|---|---|
committer | Jiang Jiang <jiang.jiang@nokia.com> | 2011-05-20 08:22:13 (GMT) |
commit | d80949eee06ff464d58bd97a6c89bae7e961f3c8 (patch) | |
tree | 760e1ba774d2cfcd9da4e7d2bee6c776cd1f86ed | |
parent | 29a6523dd8d3fac9be198c73153691c6dcdb3b21 (diff) | |
download | Qt-d80949eee06ff464d58bd97a6c89bae7e961f3c8.zip Qt-d80949eee06ff464d58bd97a6c89bae7e961f3c8.tar.gz Qt-d80949eee06ff464d58bd97a6c89bae7e961f3c8.tar.bz2 |
Fix ligature offset in multi-line text
Reviewed-by: Eskil
-rw-r--r-- | src/gui/text/qtextlayout.cpp | 4 | ||||
-rw-r--r-- | tests/auto/qtextlayout/tst_qtextlayout.cpp | 17 |
2 files changed, 19 insertions, 2 deletions
diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp index 7328ea9..de4ca4f 100644 --- a/src/gui/text/qtextlayout.cpp +++ b/src/gui/text/qtextlayout.cpp @@ -2505,8 +2505,8 @@ qreal QTextLine::cursorToX(int *cursorPos, Edge edge) const if(pos == l) x += si->width; } else { + int end = qMin(lineEnd, si->position + l) - si->position; if (reverse) { - int end = qMin(lineEnd, si->position + l) - si->position; int glyph_end = end == l ? si->num_glyphs : logClusters[end]; for (int i = glyph_end - 1; i >= glyph_pos; i--) x += glyphs.effectiveAdvance(i); @@ -2516,7 +2516,7 @@ qreal QTextLine::cursorToX(int *cursorPos, Edge edge) const for (int i = glyph_start; i < glyph_pos; i++) x += glyphs.effectiveAdvance(i); } - x += offsetInLigature(logClusters, glyphs, pos, line.length, glyph_pos); + x += offsetInLigature(logClusters, glyphs, pos, end, glyph_pos); } *cursorPos = pos + si->position; diff --git a/tests/auto/qtextlayout/tst_qtextlayout.cpp b/tests/auto/qtextlayout/tst_qtextlayout.cpp index ad33b70..964679a 100644 --- a/tests/auto/qtextlayout/tst_qtextlayout.cpp +++ b/tests/auto/qtextlayout/tst_qtextlayout.cpp @@ -126,6 +126,7 @@ private slots: void textWidthWithStackedTextEngine(); void textWidthWithLineSeparator(); void textWithSurrogates_qtbug15679(); + void cursorInLigatureWithMultipleLines(); private: QFont testFont; @@ -1436,5 +1437,21 @@ void tst_QTextLayout::textWithSurrogates_qtbug15679() QCOMPARE(x[2] - x[0], x[5] - x[3]); } +void tst_QTextLayout::cursorInLigatureWithMultipleLines() +{ +#if !defined(Q_WS_MAC) + QSKIP("This test can only be run on Mac", SkipAll); +#endif + QTextLayout layout("first line finish", QFont("Times", 20)); + layout.beginLayout(); + QTextLine line = layout.createLine(); + line.setLineWidth(70); + line = layout.createLine(); + layout.endLayout(); + + // The second line will be "finish", with "fi" as a ligature + QVERIFY(line.cursorToX(0) != line.cursorToX(1)); +} + QTEST_MAIN(tst_QTextLayout) #include "tst_qtextlayout.moc" |