aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/items/qquicktextutil.cpp
diff options
context:
space:
mode:
authorArjen Hiemstra <ahiemstra@heimr.nl>2020-03-30 14:24:44 +0200
committerEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>2020-04-29 20:17:24 +0000
commitc8bba05dc54231dbc5dc859f125d64b640e25a41 (patch)
tree0b3ea5d30c4691d165f7cd6cb5b850d8f6208b25 /src/quick/items/qquicktextutil.cpp
parent22d708697f62d2fbd69b57fd8bc3423af76d27ca (diff)
Text: Fix kerning when horizontalAlignment is set to center
When horizontalAlignment is set to center, alignedX will potentially return a position that is not pixel-aligned. This causes issues with text layout lower in the stack, leading to incorrect kerning. Rounding the position makes sure we always have a pixel-aligned position. Note that this adapts the same alignment approach as centering done by anchors, so the two will now be more consistent. [ChangeLog][QtQuick][Text] Fixed kerning when horizontalAlignment is set to center. Fixes: QTBUG-49646 Change-Id: I6ce660b0c12435a27998cba78f2c0e98d1d92cc6 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
Diffstat (limited to 'src/quick/items/qquicktextutil.cpp')
-rw-r--r--src/quick/items/qquicktextutil.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/quick/items/qquicktextutil.cpp b/src/quick/items/qquicktextutil.cpp
index eb356a9c48..024b2b7a5b 100644
--- a/src/quick/items/qquicktextutil.cpp
+++ b/src/quick/items/qquicktextutil.cpp
@@ -87,7 +87,7 @@ qreal QQuickTextUtil::alignedX(const qreal textWidth, const qreal itemWidth, int
x = itemWidth - textWidth;
break;
case Qt::AlignHCenter:
- x = (itemWidth - textWidth) / 2;
+ x = qRound(itemWidth / 2.0) - textWidth / 2.0;
break;
}
return x;