From c69469ff12eeed23584b5c3b15978a7e75d01df1 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Mon, 13 Sep 2010 14:05:54 +0200 Subject: Linux: Fix mispositioned, misclipped glyphs in large fonts (QStaticText) While drawText() will use the path fallback for large fonts, and never hit this problem, QStaticText will draw the large fonts into the glyph cache. This broke when the freetype (or any other font engine) falls back to the generic implementation of alphaMapForGlyph() which uses path drawing. The problem was that alphaMapForGlyph() is not supposed to contain the bearing of the glyph, only the actual pixels. Since QFontEngine did not honor this contract, we would sample the wrong area in the glyph cache to get the glyph image. Task-number: QTBUG-12540 Reviewed-by: Gunnar --- src/gui/text/qfontengine.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/text/qfontengine.cpp b/src/gui/text/qfontengine.cpp index 1e8461f..a3f4d8a 100644 --- a/src/gui/text/qfontengine.cpp +++ b/src/gui/text/qfontengine.cpp @@ -631,10 +631,10 @@ QImage QFontEngine::alphaMapForGlyph(glyph_t glyph) if (glyph_width <= 0 || glyph_height <= 0) return QImage(); QFixedPoint pt; - pt.x = 0; + pt.x = -glyph_x; pt.y = -glyph_y; // the baseline QPainterPath path; - QImage im(glyph_width + qAbs(glyph_x) + 4, glyph_height, QImage::Format_ARGB32_Premultiplied); + QImage im(glyph_width + 4, glyph_height, QImage::Format_ARGB32_Premultiplied); im.fill(Qt::transparent); QPainter p(&im); p.setRenderHint(QPainter::Antialiasing); -- cgit v0.12