summaryrefslogtreecommitdiffstats
path: root/src/openvg/qpaintengine_vg.cpp
diff options
context:
space:
mode:
authorAlessandro Portale <alessandro.portale@nokia.com>2010-06-30 12:31:49 (GMT)
committerAlessandro Portale <alessandro.portale@nokia.com>2010-06-30 12:31:49 (GMT)
commitb0bbabe728fedb8531fc2837403856bd5ed44e1b (patch)
tree9eed2776edca239f65bd8cee06620645f3256e17 /src/openvg/qpaintengine_vg.cpp
parent398c74022e9f24bc091348721148f3c1c53b6229 (diff)
downloadQt-b0bbabe728fedb8531fc2837403856bd5ed44e1b.zip
Qt-b0bbabe728fedb8531fc2837403856bd5ed44e1b.tar.gz
Qt-b0bbabe728fedb8531fc2837403856bd5ed44e1b.tar.bz2
Avoid blurry text with OpenVG on Symbian
Qt's graphics system uses qreal as measurement unit. The established paint engines (such as "raster") implicitly round textitem coordinates for technical reasons, e.g. for optimized blitting. Some Qt based Ui libraries (such as QWidgets) can in some cases cause textitems to be drawn on non-integer coordinates. In particular, this happens when centering text. Since these libraries have been developed against the established paint engines with implicit rounding, these non-integer coordinates were never an issue. The new OpenVG paintengine took these coordinates seriously without rounding them. On some OpenVG implementations (e.g. that of some Symbian phones), this led to blurry text rendering. This patch adds coordinate rounding for unscaled, unrotated textitems to the OpenVG paintengine. So that it does the same as the raster paint engine. Task-number: QT-3071 Reviewed-By: Jason Barron
Diffstat (limited to 'src/openvg/qpaintengine_vg.cpp')
-rw-r--r--src/openvg/qpaintengine_vg.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/openvg/qpaintengine_vg.cpp b/src/openvg/qpaintengine_vg.cpp
index cfc481e..515197a 100644
--- a/src/openvg/qpaintengine_vg.cpp
+++ b/src/openvg/qpaintengine_vg.cpp
@@ -3424,7 +3424,13 @@ void QVGPaintEngine::drawTextItem(const QPointF &p, const QTextItem &textItem)
// Set the transformation to use for drawing the current glyphs.
QTransform glyphTransform(d->pathTransform);
- glyphTransform.translate(p.x(), p.y());
+ if (d->transform.type() <= QTransform::TxTranslate) {
+ // Prevent blurriness of unscaled, unrotated text by using integer coordinates.
+ // Using ceil(x-0.5) instead of qRound() or int-cast, behave like other paint engines.
+ glyphTransform.translate(ceil(p.x() - 0.5), ceil(p.y() - 0.5));
+ } else {
+ glyphTransform.translate(p.x(), p.y());
+ }
#if defined(QVG_NO_IMAGE_GLYPHS)
glyphTransform.scale(glyphCache->scaleX, glyphCache->scaleY);
#endif