From 1a8a36eb6b6df9e2550b5eaa4606f2d411fd4294 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Wed, 24 Aug 2011 09:13:45 +0200 Subject: Fix justification of RTL text Since the trailing space is included in the QScriptLine, it may affect the positions of preceding script items when the text is RTL. The best solution for this would be to disregard the trailing space in the layout process, or somehow make it have an advance of 0 so it doesn't affect the layout. However, to minimize the impact of the change, and to be consistent with previous work arounds such as bf992df6434fc37715f728ca09601c5567dd83c9, we simply include the trailing (visually leading) space in the justification pass for now. Task-number: QTBUG-20920 Reviewed-by: Lars --- src/gui/text/qtextengine.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp index 9f148ee..aa4a20d 100644 --- a/src/gui/text/qtextengine.cpp +++ b/src/gui/text/qtextengine.cpp @@ -2087,7 +2087,8 @@ void QTextEngine::justify(const QScriptLine &line) } } - QFixed need = line.width - line.textWidth; + QFixed leading = leadingSpaceWidth(line); + QFixed need = line.width - line.textWidth - leading; if (need < 0) { // line overflows already! const_cast(line).justified = true; -- cgit v0.12