From c298b0b153b91505b83d2a5f105194b18ae0d710 Mon Sep 17 00:00:00 2001 From: Jiang Jiang Date: Thu, 8 Sep 2011 16:31:53 +0200 Subject: Fix trailing spaces problem by not adding it to QScriptLine.length It seems to be the only sane way to fix it. Previous attempts to fix it by compensating the trailing space width all failed in some cases, one of the trickiest is when we are having embedded LTR text that has trailing spaces in a RTL paragraph. In this patch we leave line.length not including the trailing space length, but saving it to a separated variable, so that we can always add it back when needed (QTextLine::textLength() for instance). It fixed all the problems in different alignments of both RTL and LTR text. And no regression is found yet. Reviewed-by: Eskil (cherry picked from commit 80294c375eca9687d1c34e9ab048294373e7f00c) Change-Id: Id248ab6f54f8cc25ba0e9d1626703463dfefbcea Reviewed-on: http://codereview.qt-project.org/4778 Reviewed-by: Jiang Jiang Reviewed-by: Qt Sanity Bot --- src/gui/text/qtextengine_p.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/gui/text/qtextengine_p.h') diff --git a/src/gui/text/qtextengine_p.h b/src/gui/text/qtextengine_p.h index 325623fc63..fd11b9f658 100644 --- a/src/gui/text/qtextengine_p.h +++ b/src/gui/text/qtextengine_p.h @@ -378,7 +378,7 @@ struct Q_AUTOTEST_EXPORT QScriptLine { // created and filled in QTextLine::layout_helper QScriptLine() - : from(0), length(0), + : from(0), trailingSpaces(0), length(0), justified(0), gridfitted(0), hasTrailingSpaces(0), leadingIncluded(0) {} QFixed descent; @@ -390,6 +390,7 @@ struct Q_AUTOTEST_EXPORT QScriptLine QFixed textWidth; QFixed textAdvance; int from; + unsigned short trailingSpaces; signed int length : 28; mutable uint justified : 1; mutable uint gridfitted : 1; -- cgit v1.2.3