diff options
author | Eskil Abrahamsen Blomfeldt <eblomfel@trolltech.com> | 2009-08-20 10:57:34 (GMT) |
---|---|---|
committer | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com> | 2010-01-14 12:57:10 (GMT) |
commit | 7fbffd29e5904151a3a249004031d0502a16f4fc (patch) | |
tree | d06b39d9993a382a01e250e58d8e547a0cd5a436 /tests/auto | |
parent | 161f6b4ccdec38c9817672ad977f4d025acb14f4 (diff) | |
download | Qt-7fbffd29e5904151a3a249004031d0502a16f4fc.zip Qt-7fbffd29e5904151a3a249004031d0502a16f4fc.tar.gz Qt-7fbffd29e5904151a3a249004031d0502a16f4fc.tar.bz2 |
Remove font property in QStaticText and fix handling translation on
painter
1. The font property in QStaticText has been removed. Rather than set a
font on the text explicitly, it picks up the font from the painter. If
you change the font on the painter, the text layout will have to be
updated, like with a matrix.
2. The translation might not be the only transformation on the painter,
so rather than translate back to origo, we explicitly set dx and dy
on the transform to 0.0 for the duration of the function.
3. Update test to reflect changes
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/qstatictext/tst_qstatictext.cpp | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/tests/auto/qstatictext/tst_qstatictext.cpp b/tests/auto/qstatictext/tst_qstatictext.cpp index 3a407c8..0e1532b 100644 --- a/tests/auto/qstatictext/tst_qstatictext.cpp +++ b/tests/auto/qstatictext/tst_qstatictext.cpp @@ -112,7 +112,7 @@ void tst_QStaticText::drawToRect() QImage imageDrawStaticText(1000, 1000, QImage::Format_ARGB32_Premultiplied); { QPainter p(&imageDrawStaticText); - QStaticText text("Lorem ipsum dolor sit amet, consectetur adipiscing elit.", QFont(), QSizeF(10, 500)); + QStaticText text("Lorem ipsum dolor sit amet, consectetur adipiscing elit.", QSizeF(10, 500)); p.drawStaticText(11, 12, text); } @@ -128,6 +128,8 @@ void tst_QStaticText::setFont() QImage imageDrawText(1000, 1000, QImage::Format_ARGB32_Premultiplied); { QPainter p(&imageDrawText); + p.drawText(0, 0, "Lorem ipsum dolor sit amet, consectetur adipiscing elit."); + p.setFont(font); p.drawText(11, 120, "Lorem ipsum dolor sit amet, consectetur adipiscing elit."); } @@ -135,9 +137,12 @@ void tst_QStaticText::setFont() QImage imageDrawStaticText(1000, 1000, QImage::Format_ARGB32_Premultiplied); { QPainter p(&imageDrawStaticText); + QStaticText text; text.setText("Lorem ipsum dolor sit amet, consectetur adipiscing elit."); - text.setFont(font); + + p.drawStaticText(0, 0, text); + p.setFont(font); p.drawStaticText(11, 120, text); } @@ -300,6 +305,7 @@ void tst_QStaticText::translationDoesntCauseRelayout() QImage imageDrawText(1000, 1000, QImage::Format_ARGB32_Premultiplied); { QPainter p(&imageDrawText); + p.scale(2.0, 2.0); p.drawText(0, 0, "Lorem ipsum dolor sit amet, consectetur adipiscing elit."); p.translate(100, 200); @@ -309,15 +315,15 @@ void tst_QStaticText::translationDoesntCauseRelayout() QImage imageDrawStaticText(1000, 1000, QImage::Format_ARGB32_Premultiplied); { QPainter p(&imageDrawStaticText); + p.scale(2.0, 2.0); QStaticText text("Lorem ipsum dolor sit amet, consectetur adipiscing elit."); + p.drawStaticText(0, 0, text); QStaticTextPrivate *textd = QStaticTextPrivate::get(&text); glyph_t *glyphPool = textd->glyphPool; QFixedPoint *positionPool = textd->positionPool; QStaticTextItem *items = textd->items; - p.drawStaticText(0, 0, text); - p.translate(100, 200); p.drawStaticText(0, 0, text); @@ -329,6 +335,11 @@ void tst_QStaticText::translationDoesntCauseRelayout() QCOMPARE(textd->items, items); } +#if defined(DEBUG_SAVE_IMAGE) + imageDrawText.save("translationDoesntCauseRelayout_imageDrawText.png"); + imageDrawStaticText.save("translationDoesntCauseRelayout_imageDrawStaticText.png"); +#endif + QCOMPARE(imageDrawStaticText, imageDrawText); } |