summaryrefslogtreecommitdiffstats
path: root/src/gui/text
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>2010-03-25 09:22:53 (GMT)
committerEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>2010-03-25 09:22:53 (GMT)
commit76267b3608836e1cc46171921caf725cfbd2ecf7 (patch)
tree33d1b19832a7613b6704b7f8b16103ad9b622d2d /src/gui/text
parentbbf096c7ba589d05df8b8bce724e9393deb8f3b4 (diff)
downloadQt-76267b3608836e1cc46171921caf725cfbd2ecf7.zip
Qt-76267b3608836e1cc46171921caf725cfbd2ecf7.tar.gz
Qt-76267b3608836e1cc46171921caf725cfbd2ecf7.tar.bz2
Fix QFontMetrics::height() and QFontMetrics autotest
Since the Mac font engine has been fixed to support fractional metrics, we can no longer expect qRound(A + B) to be equal to qRound(A) + qRound(B). The documentation states that height = ascent + descent + 1. To honor this contract, we need to rewrite the implementation of height() to round each metric separately. Same with lineSpacing. The bearingIncludedInBoundingrect() test was wrong. We can guarantee that the italic text is not more narrow than the normal text, but we cannot guarantee that they are never the same width. Reviewed-by: Olivier
Diffstat (limited to 'src/gui/text')
-rw-r--r--src/gui/text/qfontmetrics.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/gui/text/qfontmetrics.cpp b/src/gui/text/qfontmetrics.cpp
index 13a5704..7f9ae8b 100644
--- a/src/gui/text/qfontmetrics.cpp
+++ b/src/gui/text/qfontmetrics.cpp
@@ -328,7 +328,7 @@ int QFontMetrics::height() const
{
QFontEngine *engine = d->engineForScript(QUnicodeTables::Common);
Q_ASSERT(engine != 0);
- return qRound(engine->ascent() + engine->descent()) + 1;
+ return qRound(engine->ascent()) + qRound(engine->descent()) + 1;
}
/*!
@@ -356,7 +356,7 @@ int QFontMetrics::lineSpacing() const
{
QFontEngine *engine = d->engineForScript(QUnicodeTables::Common);
Q_ASSERT(engine != 0);
- return qRound(engine->leading() + engine->ascent() + engine->descent()) + 1;
+ return qRound(engine->leading()) + qRound(engine->ascent()) + qRound(engine->descent()) + 1;
}
/*!