From 1cf99d7cfeb5e446c22e52974ce6402e04a02d01 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Wed, 25 Feb 2015 12:54:15 +0100 Subject: [PATCH] Fix underline for centered text The position of the text itself is always floored, since the glyph contains the subpixel antialiasing. Since no antialiasing is applied to the underline, its position also has to be floored, otherwise it will sometimes appear one pixel to the right of the text it's underlining. [ChangeLog][Text] Fixed position of underline on centered text when the text layout's width is an even number. Task-number: QTBUG-39286 Change-Id: Ib1704ac5b09289f5b3f5a6580443f234d6d868fc Reviewed-by: Konstantin Ritt --- src/gui/painting/qpainter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp index 01f9904798..bdbb49ff51 100644 --- a/src/gui/painting/qpainter.cpp +++ b/src/gui/painting/qpainter.cpp @@ -6215,7 +6215,7 @@ static void drawTextItemDecoration(QPainter *painter, const QPointF &pos, const pen.setWidthF(fe->lineThickness().toReal()); pen.setCapStyle(Qt::FlatCap); - QLineF line(pos.x(), pos.y(), pos.x() + width, pos.y()); + QLineF line(qFloor(pos.x()), pos.y(), qFloor(pos.x() + width), pos.y()); bool wasCompatiblePainting = painter->renderHints() & QPainter::Qt4CompatiblePainting;