summaryrefslogtreecommitdiffstats
path: root/src/gui/text/qtextlayout.cpp
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>2010-03-09 13:13:58 (GMT)
committerEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>2010-03-09 14:04:09 (GMT)
commitd85b149a5c7f3532f8e1a593a79298c9ae38a95f (patch)
tree61446d8e6a65ccc2fa0c30c2b2a345a47895b77d /src/gui/text/qtextlayout.cpp
parent6396e7a15079cb157caef319348a0bcd0b95a6a7 (diff)
downloadQt-d85b149a5c7f3532f8e1a593a79298c9ae38a95f.zip
Qt-d85b149a5c7f3532f8e1a593a79298c9ae38a95f.tar.gz
Qt-d85b149a5c7f3532f8e1a593a79298c9ae38a95f.tar.bz2
Fix alignment of text with negative right bearing
In change 5364fd96a72c89b281f0540da909fe64d0575ccf and some related changes, we made sure that the natural text width used for calculating bounding rects and line breaks in the text, takes the right bearing of the last glyph into consideration. As a side-effect, this broke alignment of text, as we want to align based on the accumulated advance of the glyphs, not based on the actual width. This is in particular important when aligning monospaced text, since the text can become misaligned if the glyphs extend beyond their advance. The bug was visible e.g. in line numbers ending with 2 in Qt Creator on X11, which would be shifted one pixel to the left compared to other line numbers. Task-number: QTBUG-8864 Reviewed-by: Thorbjørn
Diffstat (limited to 'src/gui/text/qtextlayout.cpp')
-rw-r--r--src/gui/text/qtextlayout.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp
index af91603..cc6793d 100644
--- a/src/gui/text/qtextlayout.cpp
+++ b/src/gui/text/qtextlayout.cpp
@@ -1875,6 +1875,7 @@ void QTextLine::layout_helper(int maxGlyphs)
line.textWidth += lbh.softHyphenWidth;
}
+ line.textAdvance = line.textWidth;
line.textWidth += lbh.rightBearing;
goto found;
@@ -1885,6 +1886,7 @@ void QTextLine::layout_helper(int maxGlyphs)
}
LB_DEBUG("reached end of line");
lbh.checkFullOtherwiseExtend(line);
+ line.textAdvance = line.textWidth;
line.textWidth += lbh.rightBearing;
found: