summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/gui/text/qtextlayout.cpp3
-rw-r--r--tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp19
2 files changed, 20 insertions, 2 deletions
diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp
index 4e7398e978..f2622a7b20 100644
--- a/src/gui/text/qtextlayout.cpp
+++ b/src/gui/text/qtextlayout.cpp
@@ -2549,6 +2549,9 @@ qreal QTextLine::cursorToX(int *cursorPos, Edge edge) const
int pos = *cursorPos;
int itm;
+ const HB_CharAttributes *attributes = eng->attributes();
+ while (pos < line.from + line.length && !attributes[pos].charStop)
+ pos++;
if (pos == line.from + (int)line.length) {
// end of line ensure we have the last item on the line
itm = eng->findItem(pos-1);
diff --git a/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp b/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp
index 17955b36f2..348547b5b8 100644
--- a/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp
+++ b/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp
@@ -139,6 +139,7 @@ private slots:
void textWidthWithLineSeparator();
void cursorInLigatureWithMultipleLines();
void xToCursorForLigatures();
+ void cursorInNonStopChars();
private:
QFont testFont;
@@ -1472,7 +1473,7 @@ void tst_QTextLayout::textWidthWithLineSeparator()
void tst_QTextLayout::cursorInLigatureWithMultipleLines()
{
#if !defined(Q_WS_MAC)
- QSKIP("This test can not be run on Mac");
+ QSKIP("This test can only be run on Mac");
#endif
QTextLayout layout("first line finish", QFont("Times", 20));
layout.beginLayout();
@@ -1488,7 +1489,7 @@ void tst_QTextLayout::cursorInLigatureWithMultipleLines()
void tst_QTextLayout::xToCursorForLigatures()
{
#if !defined(Q_WS_MAC)
- QSKIP("This test can not be run on Mac");
+ QSKIP("This test can only be run on Mac");
#endif
QTextLayout layout("fi", QFont("Times", 20));
layout.beginLayout();
@@ -1509,5 +1510,19 @@ void tst_QTextLayout::xToCursorForLigatures()
line.xToCursor(width) == line.xToCursor(width / 2));
}
+void tst_QTextLayout::cursorInNonStopChars()
+{
+#if defined(Q_WS_MAC)
+ QSKIP("This test can not be run on Mac", SkipAll);
+#endif
+ QTextLayout layout(QString::fromUtf8("\xE0\xA4\xA4\xE0\xA5\x8D\xE0\xA4\xA8"));
+ layout.beginLayout();
+ QTextLine line = layout.createLine();
+ layout.endLayout();
+
+ QVERIFY(line.cursorToX(1) == line.cursorToX(3));
+ QVERIFY(line.cursorToX(2) == line.cursorToX(3));
+}
+
QTEST_MAIN(tst_QTextLayout)
#include "tst_qtextlayout.moc"