diff options
author | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com> | 2010-05-07 14:23:10 (GMT) |
---|---|---|
committer | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com> | 2010-05-10 08:41:13 (GMT) |
commit | 37b45fe0415bd6695640b26eb7545280b2e8ffe1 (patch) | |
tree | ea5ba66c52cb396873a668fd965ec13d78b02be5 /src/gui/text | |
parent | 18480fd6cec52722d9d096991790e32837a7ebd8 (diff) | |
download | Qt-37b45fe0415bd6695640b26eb7545280b2e8ffe1.zip Qt-37b45fe0415bd6695640b26eb7545280b2e8ffe1.tar.gz Qt-37b45fe0415bd6695640b26eb7545280b2e8ffe1.tar.bz2 |
Fix off-by-one in text layouts and widget size hints on Mac
The mac font engine was made to return fractional values. This has
exposed a few bugs where the rounded height of the font was used for
text layouts and widget size hints. Since a fractional part of the
font's height also creates pixels, rounding the height down in these
cases is always wrong.
The biggest culprit was QScriptLine::height. This is used to lay out
text lines and returning a fractional height created problems all
over the place. Rather than ceil the number in all places where it
is used, we simply return a ceiled value for the line's height.
In 4.6, this value would be qRound(ascent)+qRound(descent)+1,
which would in some cases cause the previous and current line to
overlap by one pixel. By ceiling the sum of the two, we guarantee
that the text line contains the complete bounds of the font.
A note about the removal of the code that gets the font metrics for
QSmallFont: The condition would never be true since this is inside
a branch which is only evaluated if fontIsSet is true.
Task-number: QTBUG-9971
Reviewed-by: Gunnar
Diffstat (limited to 'src/gui/text')
-rw-r--r-- | src/gui/text/qtextengine_p.h | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/gui/text/qtextengine_p.h b/src/gui/text/qtextengine_p.h index 5054b66..d92148f 100644 --- a/src/gui/text/qtextengine_p.h +++ b/src/gui/text/qtextengine_p.h @@ -389,7 +389,7 @@ struct Q_AUTOTEST_EXPORT QScriptLine mutable uint gridfitted : 1; uint hasTrailingSpaces : 1; uint leadingIncluded : 1; - QFixed height() const { return ascent + descent + 1 + QFixed height() const { return (ascent + descent).ceil() + 1 + (leadingIncluded? qMax(QFixed(),leading) : QFixed()); } QFixed base() const { return ascent + (leadingIncluded ? qMax(QFixed(),leading) : QFixed()); } |