From f9399d69add411adf757e3390488ff57655833b7 Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Fri, 8 Nov 2013 12:28:23 +0100 Subject: Force FT font engine to load the right glyph metrics Change-Id: If027ea4c1a3b2ca8f972592abe3534165f62cf4e Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/gui/painting/qtextureglyphcache.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src') diff --git a/src/gui/painting/qtextureglyphcache.cpp b/src/gui/painting/qtextureglyphcache.cpp index 2166ae7975..b953f8d81f 100644 --- a/src/gui/painting/qtextureglyphcache.cpp +++ b/src/gui/painting/qtextureglyphcache.cpp @@ -152,6 +152,18 @@ bool QTextureGlyphCache::populate(QFontEngine *fontEngine, int numGlyphs, const continue; if (listItemCoordinates.contains(GlyphAndSubPixelPosition(glyph, subPixelPosition))) continue; + + // This is a rather crude hack, but it works. + // The FreeType font engine is not capable of getting precise metrics for the alphamap + // without first rasterizing the glyph. If we force the glyph to be rasterized before + // we ask for the alphaMapBoundingBox(), the glyph will be loaded, rasterized and its + // proper metrics will be cached and used later. + if (fontEngine->hasInternalCaching()) { + QImage *locked = fontEngine->lockedAlphaMapForGlyph(glyph, subPixelPosition, format); + if (locked) + fontEngine->unlockAlphaMapForGlyph(); + } + glyph_metrics_t metrics = fontEngine->alphaMapBoundingBox(glyph, subPixelPosition, m_transform, format); #ifdef CACHE_DEBUG -- cgit v1.2.3