summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJiang Jiang <jiang.jiang@nokia.com>2011-05-19 10:29:49 +0200
committerQt Continuous Integration System <qt-info@nokia.com>2011-05-30 15:16:34 +0200
commit9f837af9458ea4825b9a8061de444f62d8a7a048 (patch)
tree5aa4209b61c740a749dff50213d9e0733aedebba /tests
parenta4ecb10eff83747ed0fec220071d6649722dc1a7 (diff)
Support placing cursor in ligature with mouse or touch
We need to find out the closest element in the ligature to the point we clicked (or tapped), currently we do this by dividing the width of that ligature glyph evenly by the number of characters it covered. We only support Common and Greek script at this point, ligatures in other scripts are still handled as a whole. Task-number: QTBUG-19260 Reviewed-by: Eskil (cherry picked from commit 5338d78aa9d80ddd2bcb21e6b22cd2cf1522a7d3) Change-Id: Ic747e9458d561aca0848dcd1e8b94e0a23fd8189 Reviewed-on: http://codereview.qt.nokia.com/196 Reviewed-by: Jiang Jiang <jiang.jiang@nokia.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qtextlayout/tst_qtextlayout.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/auto/qtextlayout/tst_qtextlayout.cpp b/tests/auto/qtextlayout/tst_qtextlayout.cpp
index be0a83fe38..2414ab3e37 100644
--- a/tests/auto/qtextlayout/tst_qtextlayout.cpp
+++ b/tests/auto/qtextlayout/tst_qtextlayout.cpp
@@ -128,6 +128,7 @@ private slots:
void textWidthWithStackedTextEngine();
void textWidthWithLineSeparator();
void cursorInLigatureWithMultipleLines();
+ void xToCursorForLigatures();
private:
QFont testFont;
@@ -1477,5 +1478,29 @@ void tst_QTextLayout::cursorInLigatureWithMultipleLines()
QVERIFY(line.cursorToX(0) != line.cursorToX(1));
}
+void tst_QTextLayout::xToCursorForLigatures()
+{
+#if !defined(Q_WS_MAC)
+ QSKIP("This test can not be run on Mac", SkipAll);
+#endif
+ QTextLayout layout("fi", QFont("Times", 20));
+ layout.beginLayout();
+ QTextLine line = layout.createLine();
+ layout.endLayout();
+
+ QVERIFY(line.xToCursor(0) != line.xToCursor(line.naturalTextWidth() / 2));
+
+ // U+0061 U+0308
+ QTextLayout layout2(QString::fromUtf8("\x61\xCC\x88"), QFont("Times", 20));
+
+ layout2.beginLayout();
+ line = layout2.createLine();
+ layout2.endLayout();
+
+ qreal width = line.naturalTextWidth();
+ QVERIFY(line.xToCursor(0) == line.xToCursor(width / 2) ||
+ line.xToCursor(width) == line.xToCursor(width / 2));
+}
+
QTEST_MAIN(tst_QTextLayout)
#include "tst_qtextlayout.moc"