From 40b6c1dd9199ac5e0d6a1921b05c11e647d09dca Mon Sep 17 00:00:00 2001 From: Jiang Jiang Date: Thu, 26 Aug 2010 16:16:59 +0200 Subject: Correct last right bearing in boundingBox(glyphs) Commit 07880542ecc479807c23c5646d263135240822ff introduced regression to QFontMetrics::boundingRect and QTextEngine::boundingBox on FT, XLFD and QPF font engine. Because on these platforms, rightBearing of the last glyphs is already removed from the width returned in glyph_metrics_t. Subtracting that rightBearing twice will cause the resulting boundingBox smaller than expected. This patch fix this by removing last right bearing accounting code from generic QTextEngine::boundingBox, instead, we put it into font engines that need them: QFontEngineWin, QCoreTextFontEngine, QFontEngineMac, QFontEngineS60 and QFontEngineQWS. So that the resulting width should be correct on all platforms without introducing any performance penalties. Task-number: QTBUG-6854, QTBUG-12950 Reviewed-by: Eskil --- src/gui/text/qfontengine.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/gui/text/qfontengine.cpp') diff --git a/src/gui/text/qfontengine.cpp b/src/gui/text/qfontengine.cpp index 194c5f3dd4..3f758b1dd2 100644 --- a/src/gui/text/qfontengine.cpp +++ b/src/gui/text/qfontengine.cpp @@ -1093,6 +1093,18 @@ const QVector &QFontEngine::grayPalette() return *qt_grayPalette(); } +QFixed QFontEngine::lastRightBearing(const QGlyphLayout &glyphs, bool round) +{ + if (glyphs.numGlyphs >= 1) { + glyph_t glyph = glyphs.glyphs[glyphs.numGlyphs - 1]; + glyph_metrics_t gi = boundingBox(glyph); + if (gi.isValid()) + return round ? QFixed(qRound(gi.xoff - gi.x - gi.width)) + : QFixed(gi.xoff - gi.x - gi.width); + } + return 0; +} + // ------------------------------------------------------------------ // The box font engine // ------------------------------------------------------------------ -- cgit v1.2.3