diff options
author | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com> | 2012-02-03 14:28:16 +0100 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-02-17 05:26:44 +0100 |
commit | cb8445f0323b0eefbb04f1d8adad81a00b53abd8 (patch) | |
tree | 502411d2ce366cb25a1ac9424eb314c320ece905 /src/gui/text | |
parent | 2801db558c56e98753e297c1aeabd4fd2975e09a (diff) |
Remove historical +1 from font height calculation
Historically, we've calculated font height as ascent+descent+1.
In Qt 4, a patch was added to work around this by subtracting
1 from the descent of the font engines. We now remove the +1 and
the work arounds.
Change-Id: I7e25d49b97ac892015d3328f32d70eb9a7c2d88f
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Diffstat (limited to 'src/gui/text')
-rw-r--r-- | src/gui/text/qabstracttextdocumentlayout.cpp | 2 | ||||
-rw-r--r-- | src/gui/text/qfontengine_ft.cpp | 5 | ||||
-rw-r--r-- | src/gui/text/qfontenginedirectwrite.cpp | 4 | ||||
-rw-r--r-- | src/gui/text/qfontmetrics.cpp | 8 | ||||
-rw-r--r-- | src/gui/text/qtextengine_p.h | 4 | ||||
-rw-r--r-- | src/gui/text/qtextlayout.cpp | 4 |
6 files changed, 13 insertions, 14 deletions
diff --git a/src/gui/text/qabstracttextdocumentlayout.cpp b/src/gui/text/qabstracttextdocumentlayout.cpp index 2c22b72846..7bf2a631ea 100644 --- a/src/gui/text/qabstracttextdocumentlayout.cpp +++ b/src/gui/text/qabstracttextdocumentlayout.cpp @@ -469,7 +469,7 @@ void QAbstractTextDocumentLayout::resizeInlineObject(QTextInlineObject item, int QSizeF s = handler.iface->intrinsicSize(document(), posInDocument, format); item.setWidth(s.width()); - item.setAscent(s.height() - 1); + item.setAscent(s.height()); item.setDescent(0); } diff --git a/src/gui/text/qfontengine_ft.cpp b/src/gui/text/qfontengine_ft.cpp index c9eadd386e..8880eb7cb3 100644 --- a/src/gui/text/qfontengine_ft.cpp +++ b/src/gui/text/qfontengine_ft.cpp @@ -1173,8 +1173,7 @@ QFixed QFontEngineFT::ascent() const QFixed QFontEngineFT::descent() const { - // subtract a pixel to work around QFontMetrics's built-in + 1 - return QFixed::fromFixed(-metrics.descender - 64); + return QFixed::fromFixed(-metrics.descender); } QFixed QFontEngineFT::leading() const @@ -1589,7 +1588,7 @@ glyph_metrics_t QFontEngineFT::boundingBox(const QGlyphLayout &glyphs) glyph_metrics_t overall; // initialize with line height, we get the same behaviour on all platforms overall.y = -ascent(); - overall.height = ascent() + descent() + 1; + overall.height = ascent() + descent(); QFixed ymax = 0; QFixed xmax = 0; diff --git a/src/gui/text/qfontenginedirectwrite.cpp b/src/gui/text/qfontenginedirectwrite.cpp index afbc41daeb..0f21ae8a1e 100644 --- a/src/gui/text/qfontenginedirectwrite.cpp +++ b/src/gui/text/qfontenginedirectwrite.cpp @@ -484,8 +484,8 @@ QFixed QFontEngineDirectWrite::ascent() const QFixed QFontEngineDirectWrite::descent() const { return fontDef.styleStrategy & QFont::ForceIntegerMetrics - ? (m_descent - 1).round() - : (m_descent - 1); + ? (m_descent).round() + : (m_descent); } QFixed QFontEngineDirectWrite::leading() const diff --git a/src/gui/text/qfontmetrics.cpp b/src/gui/text/qfontmetrics.cpp index a2f0dd724a..283494e316 100644 --- a/src/gui/text/qfontmetrics.cpp +++ b/src/gui/text/qfontmetrics.cpp @@ -288,7 +288,7 @@ int QFontMetrics::height() const { QFontEngine *engine = d->engineForScript(QUnicodeTables::Common); Q_ASSERT(engine != 0); - return qRound(engine->ascent()) + qRound(engine->descent()) + 1; + return qRound(engine->ascent()) + qRound(engine->descent()); } /*! @@ -316,7 +316,7 @@ int QFontMetrics::lineSpacing() const { QFontEngine *engine = d->engineForScript(QUnicodeTables::Common); Q_ASSERT(engine != 0); - return qRound(engine->leading()) + qRound(engine->ascent()) + qRound(engine->descent()) + 1; + return qRound(engine->leading()) + qRound(engine->ascent()) + qRound(engine->descent()); } /*! @@ -1147,7 +1147,7 @@ qreal QFontMetricsF::height() const QFontEngine *engine = d->engineForScript(QUnicodeTables::Common); Q_ASSERT(engine != 0); - return (engine->ascent() + engine->descent() + 1).toReal(); + return (engine->ascent() + engine->descent()).toReal(); } /*! @@ -1175,7 +1175,7 @@ qreal QFontMetricsF::lineSpacing() const { QFontEngine *engine = d->engineForScript(QUnicodeTables::Common); Q_ASSERT(engine != 0); - return (engine->leading() + engine->ascent() + engine->descent() + 1).toReal(); + return (engine->leading() + engine->ascent() + engine->descent()).toReal(); } /*! diff --git a/src/gui/text/qtextengine_p.h b/src/gui/text/qtextengine_p.h index 53031cfcee..b29f626b68 100644 --- a/src/gui/text/qtextengine_p.h +++ b/src/gui/text/qtextengine_p.h @@ -366,7 +366,7 @@ struct Q_AUTOTEST_EXPORT QScriptItem QFixed leading; QFixed width; int glyph_data_offset; - QFixed height() const { return ascent + descent + 1; } + QFixed height() const { return ascent + descent; } }; @@ -396,7 +396,7 @@ struct Q_AUTOTEST_EXPORT QScriptLine mutable uint gridfitted : 1; uint hasTrailingSpaces : 1; uint leadingIncluded : 1; - QFixed height() const { return (ascent + descent).ceil() + 1 + QFixed height() const { return (ascent + descent).ceil() + (leadingIncluded? qMax(QFixed(),leading) : QFixed()); } QFixed base() const { return ascent + (leadingIncluded ? qMax(QFixed(),leading) : QFixed()); } diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp index 84d3fce518..943caea644 100644 --- a/src/gui/text/qtextlayout.cpp +++ b/src/gui/text/qtextlayout.cpp @@ -1429,9 +1429,9 @@ qreal QTextLine::descent() const } /*! - Returns the line's height. This is equal to ascent() + descent() + 1 + Returns the line's height. This is equal to ascent() + descent() if leading is not included. If leading is included, this equals to - ascent() + descent() + leading() + 1. + ascent() + descent() + leading(). \sa ascent(), descent(), leading(), setLeadingIncluded() */ |