diff options
author | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com> | 2010-09-07 11:57:07 (GMT) |
---|---|---|
committer | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com> | 2010-09-09 15:12:04 (GMT) |
commit | b7ef9d49a969f512ecbc7ad940642f3a74e348ad (patch) | |
tree | a73e4b3fd5a8ffd6b2055f83618f56dfd6ef129a /tests/auto/qpainter | |
parent | de1b1cd7a6a15755bd5f049533791554c933686c (diff) | |
download | Qt-b7ef9d49a969f512ecbc7ad940642f3a74e348ad.zip Qt-b7ef9d49a969f512ecbc7ad940642f3a74e348ad.tar.gz Qt-b7ef9d49a969f512ecbc7ad940642f3a74e348ad.tar.bz2 |
Support sub pixel positioning of glyphs in raster engine
For the raster engine to provide the same quality of text rendering
as the native engine on Mac Cocoa, we need to support rendering to
different sub pixel positions for each glyph. The number of
subpixel positions is arbitrary and has to be detected, but it's
usually three or four.
Each position will give slightly different coverages inside the
pixel and thus different rasterizations. Other font engines which
support sub pixel positioning of glyphs can provide the same
functionality by implementing supportsSubPixelPositions() to return
true, and then adding the subPixelPosition argument to the x
coordinate used in alphaRGBMapForGlyph().
Task-number: QTBUG-5053
Reviewed-by: Jiang Jiang
Diffstat (limited to 'tests/auto/qpainter')
-rw-r--r-- | tests/auto/qpainter/tst_qpainter.cpp | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/auto/qpainter/tst_qpainter.cpp b/tests/auto/qpainter/tst_qpainter.cpp index 1ba5859..06de16a 100644 --- a/tests/auto/qpainter/tst_qpainter.cpp +++ b/tests/auto/qpainter/tst_qpainter.cpp @@ -221,6 +221,8 @@ private slots: void drawRect_task215378(); void drawRect_task247505(); + void drawText_subPixelPositionsInRaster_qtbug5053(); + void drawImage_data(); void drawImage(); @@ -4562,6 +4564,40 @@ void tst_QPainter::clipBoundingRect() } +void tst_QPainter::drawText_subPixelPositionsInRaster_qtbug5053() +{ +#if !defined(Q_WS_MAC) + QSKIP("Only mac supports sub pixel positions currently", SkipAll); +#endif + + QFontMetricsF fm(qApp->font()); + + QImage baseLine(fm.width(QChar::fromLatin1('e')), fm.height(), QImage::Format_RGB32); + baseLine.fill(Qt::white); + { + QPainter p(&baseLine); + p.drawText(0, fm.ascent(), QString::fromLatin1("e")); + } + + bool foundDifferentRasterization = false; + for (int i=1; i<12; ++i) { + QImage comparison(baseLine.size(), QImage::Format_RGB32); + comparison.fill(Qt::white); + + { + QPainter p(&comparison); + p.drawText(QPointF(i / 12.0, fm.ascent()), QString::fromLatin1("e")); + } + + if (comparison != baseLine) { + foundDifferentRasterization = true; + break; + } + } + + QVERIFY(foundDifferentRasterization); +} + QTEST_MAIN(tst_QPainter) #include "tst_qpainter.moc" |