summaryrefslogtreecommitdiffstats
path: root/src/gui/text/qfontengine_mac.mm
diff options
context:
space:
mode:
authorJiang Jiang <jiang.jiang@nokia.com>2010-08-26 16:16:59 +0200
committerJiang Jiang <jiang.jiang@nokia.com>2010-08-27 16:51:57 +0200
commit40b6c1dd9199ac5e0d6a1921b05c11e647d09dca (patch)
tree74925154b039df1df12207ef5661fdbabe96dd5c /src/gui/text/qfontengine_mac.mm
parenta2fd1b5265b1c6e9b3d8e1a03ddb2675f5df748d (diff)
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
Diffstat (limited to 'src/gui/text/qfontengine_mac.mm')
-rw-r--r--src/gui/text/qfontengine_mac.mm17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/gui/text/qfontengine_mac.mm b/src/gui/text/qfontengine_mac.mm
index 91b608253a..bdf3848b71 100644
--- a/src/gui/text/qfontengine_mac.mm
+++ b/src/gui/text/qfontengine_mac.mm
@@ -455,12 +455,13 @@ bool QCoreTextFontEngine::stringToCMap(const QChar *, int, QGlyphLayout *, int *
glyph_metrics_t QCoreTextFontEngine::boundingBox(const QGlyphLayout &glyphs)
{
QFixed w;
+ bool round = fontDef.styleStrategy & QFont::ForceIntegerMetrics;
+
for (int i = 0; i < glyphs.numGlyphs; ++i) {
- w += (fontDef.styleStrategy & QFont::ForceIntegerMetrics)
- ? glyphs.effectiveAdvance(i).round()
- : glyphs.effectiveAdvance(i);
+ w += round ? glyphs.effectiveAdvance(i).round()
+ : glyphs.effectiveAdvance(i);
}
- return glyph_metrics_t(0, -(ascent()), w, ascent()+descent(), w, 0);
+ return glyph_metrics_t(0, -(ascent()), w - lastRightBearing(glyphs, round), ascent()+descent(), w, 0);
}
glyph_metrics_t QCoreTextFontEngine::boundingBox(glyph_t glyph)
{
@@ -1480,12 +1481,12 @@ void QFontEngineMac::recalcAdvances(QGlyphLayout *glyphs, QTextEngine::ShaperFla
glyph_metrics_t QFontEngineMac::boundingBox(const QGlyphLayout &glyphs)
{
QFixed w;
+ bool round = fontDef.styleStrategy & QFont::ForceIntegerMetrics;
for (int i = 0; i < glyphs.numGlyphs; ++i) {
- w += (fontDef.styleStrategy & QFont::ForceIntegerMetrics)
- ? glyphs.effectiveAdvance(i).round()
- : glyphs.effectiveAdvance(i);
+ w += round ? glyphs.effectiveAdvance(i).round()
+ : glyphs.effectiveAdvance(i);
}
- return glyph_metrics_t(0, -(ascent()), w, ascent()+descent(), w, 0);
+ return glyph_metrics_t(0, -(ascent()), w - lastRightBearing(glyphs, round), ascent()+descent(), w, 0);
}
glyph_metrics_t QFontEngineMac::boundingBox(glyph_t glyph)