From 5131aefc1f0c04936e3ef19c9870d884775471e5 Mon Sep 17 00:00:00 2001 From: Jiang Jiang Date: Thu, 24 May 2012 15:40:16 +0200 Subject: [PATCH] Fix text decoration width rounding MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- src/gui/painting/qpainter.cpp | 3 +-- src/gui/text/qtextengine.cpp | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp index 2a793a131e9..ed08162c1cb 100644 --- a/src/gui/painting/qpainter.cpp +++ b/src/gui/painting/qpainter.cpp @@ -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)); diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp index dbf1b457f6f..d1f168805a1 100644 --- a/src/gui/text/qtextengine.cpp +++ b/src/gui/text/qtextengine.cpp @@ -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); } }