summaryrefslogtreecommitdiffstats
path: root/tests/auto/qglyphs
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>2010-07-13 16:47:26 +0200
committerEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>2010-07-14 13:39:49 +0200
commit81856e8b008099e39465543c3e85049380256cbb (patch)
tree18d36c5561d033b08221adb97b6b225fee3e1ee9 /tests/auto/qglyphs
parent1348b33591182e16264ff15854efe849638ca04c (diff)
Support RTL text in QGlyphs
RTL text would be positioned wrong with QGlyphs, as we would not correctly detect the direction of the text and pass it into getGlyphPositions(). The bidi analysis is the same as in the QTextLine::draw() method. Reviewed-by: Kim
Diffstat (limited to 'tests/auto/qglyphs')
-rw-r--r--tests/auto/qglyphs/tst_qglyphs.cpp49
1 files changed, 49 insertions, 0 deletions
diff --git a/tests/auto/qglyphs/tst_qglyphs.cpp b/tests/auto/qglyphs/tst_qglyphs.cpp
index 6827b2352e..b75e801295 100644
--- a/tests/auto/qglyphs/tst_qglyphs.cpp
+++ b/tests/auto/qglyphs/tst_qglyphs.cpp
@@ -69,6 +69,7 @@ private slots:
void drawStruckOutText();
void drawOverlinedText();
void drawUnderlinedText();
+ void drawRightToLeft();
void detach();
private:
@@ -527,6 +528,54 @@ void tst_QGlyphs::drawUnderlinedText()
QCOMPARE(textLayoutDraw, drawGlyphs);
}
+void tst_QGlyphs::drawRightToLeft()
+{
+#if defined(Q_WS_MAC)
+ QSKIP("Unstable because of QTBUG-11145", SkipAll);
+#endif
+
+ QString s;
+ s.append(QChar(1575));
+ s.append(QChar(1578));
+
+ QPixmap textLayoutDraw(1000, 1000);
+ QPixmap drawGlyphs(1000, 1000);
+
+ textLayoutDraw.fill(Qt::white);
+ drawGlyphs.fill(Qt::white);
+
+ QFont font;
+ font.setUnderline(true);
+
+ QTextLayout layout(s);
+ layout.setFont(font);
+ layout.beginLayout();
+ layout.createLine();
+ layout.endLayout();
+
+ {
+ QPainter p(&textLayoutDraw);
+ layout.draw(&p, QPointF(50, 50));
+ }
+
+ QGlyphs glyphs = layout.glyphs().size() > 0
+ ? layout.glyphs().at(0)
+ : QGlyphs();
+
+ {
+ QPainter p(&drawGlyphs);
+ p.drawGlyphs(QPointF(50, 50), glyphs);
+ }
+
+#if defined(DEBUG_SAVE_IMAGE)
+ textLayoutDraw.save("drawRightToLeft_textLayoutDraw.png");
+ drawGlyphs.save("drawRightToLeft_drawGlyphIndexes.png");
+#endif
+
+ QCOMPARE(textLayoutDraw, drawGlyphs);
+
+}
+
QTEST_MAIN(tst_QGlyphs)
#include "tst_qglyphs.moc"