diff options
author | Samuel Rødal <sroedal@trolltech.com> | 2009-09-16 10:55:12 (GMT) |
---|---|---|
committer | Samuel Rødal <sroedal@trolltech.com> | 2009-09-21 14:37:47 (GMT) |
commit | 01383e6fde102ebeff5f87a90142c6d1cdb44d94 (patch) | |
tree | 251c00cb900517b0012b5a2780e38885c7316745 /src | |
parent | 65b4ce3c51283adb76dcb73cc654b06359b1ae00 (diff) | |
download | Qt-01383e6fde102ebeff5f87a90142c6d1cdb44d94.zip Qt-01383e6fde102ebeff5f87a90142c6d1cdb44d94.tar.gz Qt-01383e6fde102ebeff5f87a90142c6d1cdb44d94.tar.bz2 |
Made subpixel antialiasing in the GL2 engine work on X11 as well.
Need to add alphaRGBMapForGlyph to the Freetype font engine.
Reviewed-by: Kim
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/text/qfontengine_ft.cpp | 22 | ||||
-rw-r--r-- | src/gui/text/qfontengine_ft_p.h | 1 |
2 files changed, 23 insertions, 0 deletions
diff --git a/src/gui/text/qfontengine_ft.cpp b/src/gui/text/qfontengine_ft.cpp index 49149c5..a4b2e7e 100644 --- a/src/gui/text/qfontengine_ft.cpp +++ b/src/gui/text/qfontengine_ft.cpp @@ -1848,6 +1848,28 @@ QImage QFontEngineFT::alphaMapForGlyph(glyph_t g) return img; } +QImage QFontEngineFT::alphaRGBMapForGlyph(glyph_t g, int margin, const QTransform &t) +{ + if (t.type() != QTransform::TxTranslate) + return QFontEngine::alphaRGBMapForGlyph(g, margin, t); + + lockFace(); + + GlyphFormat glyph_format = Format_A32; + + Glyph *glyph = defaultGlyphSet.outline_drawing ? 0 : loadGlyph(g, glyph_format); + if (!glyph) { + unlockFace(); + return QFontEngine::alphaRGBMapForGlyph(g, margin, t); + } + + QImage img(glyph->width, glyph->height, QImage::Format_RGB32); + memcpy(img.bits(), glyph->data, 4 * glyph->width * glyph->height); + unlockFace(); + + return img; +} + void QFontEngineFT::removeGlyphFromCache(glyph_t glyph) { delete defaultGlyphSet.glyph_data.take(glyph); diff --git a/src/gui/text/qfontengine_ft_p.h b/src/gui/text/qfontengine_ft_p.h index 6704c8f..99b40f8 100644 --- a/src/gui/text/qfontengine_ft_p.h +++ b/src/gui/text/qfontengine_ft_p.h @@ -227,6 +227,7 @@ public: virtual void recalcAdvances(QGlyphLayout *glyphs, QTextEngine::ShaperFlags flags) const; virtual QImage alphaMapForGlyph(glyph_t); + virtual QImage alphaRGBMapForGlyph(glyph_t, int margin, const QTransform &t); virtual void removeGlyphFromCache(glyph_t glyph); virtual int glyphCount() const; |