summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJiang Jiang <jiang.jiang@nokia.com>2010-11-02 11:36:27 (GMT)
committerQt Commercial Integration <QtCommercial@digia.com>2012-01-31 10:24:55 (GMT)
commitdea888b354ec53e35e15ddc5a0143e4861e5d30b (patch)
treebcf4130c53e20a97fdf3654a4c497a7d620b5d45
parent93db38955314bf1f65ec5e66b23d005117358135 (diff)
downloadQt-dea888b354ec53e35e15ddc5a0143e4861e5d30b.zip
Qt-dea888b354ec53e35e15ddc5a0143e4861e5d30b.tar.gz
Qt-dea888b354ec53e35e15ddc5a0143e4861e5d30b.tar.bz2
Fix cursor position of one digit after RTL text
A single digit after RTL text will be considered as RTL because it was treated as Other Neutral (DirON), it can be solved by changing it to DirAN. Task-number: QTBUG-2795 Reviewed-by: Lars Knoll
-rw-r--r--src/gui/text/qtextengine.cpp2
-rw-r--r--tests/auto/qcomplextext/tst_qcomplextext.cpp23
2 files changed, 24 insertions, 1 deletions
diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp
index 66773c6..5cad9b7 100644
--- a/src/gui/text/qtextengine.cpp
+++ b/src/gui/text/qtextengine.cpp
@@ -612,7 +612,7 @@ static bool bidiItemize(QTextEngine *engine, QScriptAnalysis *analysis, QBidiCon
} else {
eor = current;
}
- dir = QChar::DirON; status.eor = QChar::DirAN;
+ dir = QChar::DirAN; status.eor = QChar::DirAN;
break;
case QChar::DirCS:
if(status.eor == QChar::DirAN) {
diff --git a/tests/auto/qcomplextext/tst_qcomplextext.cpp b/tests/auto/qcomplextext/tst_qcomplextext.cpp
index 1fccdb0..de08462 100644
--- a/tests/auto/qcomplextext/tst_qcomplextext.cpp
+++ b/tests/auto/qcomplextext/tst_qcomplextext.cpp
@@ -68,6 +68,7 @@ public slots:
private slots:
void bidiReorderString_data();
void bidiReorderString();
+ void bidiCursor_qtbug2795();
};
tst_QComplexText::tst_QComplexText()
@@ -159,6 +160,28 @@ void tst_QComplexText::bidiReorderString()
QTEST(visual, "VISUAL");
}
+void tst_QComplexText::bidiCursor_qtbug2795()
+{
+ QString str = QString::fromUtf8("الجزيرة نت");
+ QTextLayout l1(str);
+
+ l1.beginLayout();
+ QTextLine line1 = l1.createLine();
+ l1.endLayout();
+
+ qreal x1 = line1.cursorToX(0) - line1.cursorToX(str.size());
+
+ str.append("1");
+ QTextLayout l2(str);
+ l2.beginLayout();
+ QTextLine line2 = l2.createLine();
+ l2.endLayout();
+
+ qreal x2 = line2.cursorToX(0) - line2.cursorToX(str.size());
+
+ // The cursor should remain at the same position after a digit is appended
+ QVERIFY(x1 == x2);
+}
QTEST_MAIN(tst_QComplexText)
#include "tst_qcomplextext.moc"