Fix text decoration width rounding
authorJiang Jiang <jiang.jiang@nokia.com>
Thu, 24 May 2012 13:40:16 +0000 (15:40 +0200)
committerQt by Nokia <qt-info@nokia.com>
Wed, 30 May 2012 14:34:25 +0000 (16:34 +0200)
width passed in qreal should be set with setWidthF instead of
setWidth, otherwise the fractional part is lost.

Also remove the raster paint engine hack that has been removed in
Qt 4.8, it's no longer needed.

This fixed the drawUnderline and drawRightToLeft auto tests in
tst_qglyphrun.

Change-Id: Iace46fc27ff156c07fb4d08a145269fad36e9fdb
Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
src/gui/painting/qpainter.cpp
src/gui/text/qtextengine.cpp

index 2a793a1..ed08162 100644 (file)
@@ -6177,8 +6177,7 @@ static void drawTextItemDecoration(QPainter *painter, const QPointF &pos, const
     const qreal underlineOffset = fe->underlinePosition().toReal();
     // deliberately ceil the offset to avoid the underline coming too close to
     // the text above it.
-    const qreal aliasedCoordinateDelta = 0.5 - 0.015625;
-    const qreal underlinePos = pos.y() + qCeil(underlineOffset) - aliasedCoordinateDelta;
+    const qreal underlinePos = pos.y() + qCeil(underlineOffset);
 
     if (underlineStyle == QTextCharFormat::SpellCheckUnderline) {
         underlineStyle = QTextCharFormat::SpellCheckUnderline; // ### Qt5 QTextCharFormat::UnderlineStyle(QApplication::style()->styleHint(QStyle::SH_SpellCheckUnderlineStyle));
index dbf1b45..d1f1688 100644 (file)
@@ -3046,7 +3046,7 @@ void QTextEngine::adjustUnderlines(ItemDecorationList::iterator start,
 {
     for (ItemDecorationList::iterator it = start; it != end; ++it) {
         it->y = underlinePos;
-        it->pen.setWidth(penWidth);
+        it->pen.setWidthF(penWidth);
     }
 }