summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJiang Jiang <jiang.jiang@nokia.com>2011-07-08 13:39:36 +0200
committerQt by Nokia <qt-info@nokia.com>2011-07-20 00:01:35 +0200
commitd4af9f6f2da3eeaf5f6bdf98699312b42f37eac8 (patch)
tree5b9cc39e5ecb45a570ad66d2aa39064074e5c602
parent9a7a18f83a9f3192c3ebabadc645384beb9cd2a2 (diff)
Use truncate only for subpixel boundingBox x position
Since Lion, Core Text starts to return fractional values for x origin in the glyph bounding box. To get correct alignment we need to make it integer, it seems that round will cut certain pixels (x = 0.6 will be round to 1, then that glyph will be moved too much to the left in image glyph cache). Reverting 4297b85a appears to work fine on previous version of Mac OS X as well. This change will not affect Windows (DirectWrite) and FreeType font engines since they both return integer values for that. Change-Id: I830f5b0bd27cad3a3a84b157da428134fb979703 Reviewed-by: Eskil Reviewed-on: http://codereview.qt.nokia.com/1667 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Jiang Jiang <jiang.jiang@nokia.com>
-rw-r--r--src/gui/painting/qtextureglyphcache.cpp2
-rw-r--r--src/gui/text/qfontengine_coretext.mm4
2 files changed, 3 insertions, 3 deletions
diff --git a/src/gui/painting/qtextureglyphcache.cpp b/src/gui/painting/qtextureglyphcache.cpp
index 53fefa4fae..665efe07f2 100644
--- a/src/gui/painting/qtextureglyphcache.cpp
+++ b/src/gui/painting/qtextureglyphcache.cpp
@@ -198,7 +198,7 @@ bool QTextureGlyphCache::populate(QFontEngine *fontEngine, int numGlyphs, const
Coord c = { 0, 0, // will be filled in later
glyph_width,
glyph_height, // texture coords
- metrics.x.round().truncate(),
+ metrics.x.truncate(),
-metrics.y.truncate() }; // baseline for horizontal scripts
listItemCoordinates.insert(key, c);
diff --git a/src/gui/text/qfontengine_coretext.mm b/src/gui/text/qfontengine_coretext.mm
index 303da8d363..9943229787 100644
--- a/src/gui/text/qfontengine_coretext.mm
+++ b/src/gui/text/qfontengine_coretext.mm
@@ -750,8 +750,8 @@ QImage QCoreTextFontEngine::imageForGlyph(glyph_t glyph, QFixed subPixelPosition
CGContextSetFont(ctx, cgFont);
- qreal pos_x = -br.x.toReal() + subPixelPosition.toReal();
- qreal pos_y = im.height() + br.y.toReal() - 1;
+ qreal pos_x = -br.x.truncate() + subPixelPosition.toReal();
+ qreal pos_y = im.height() + br.y.toReal();
CGContextSetTextPosition(ctx, pos_x, pos_y);
CGSize advance;