From baea4a79bc363e37970bcc24cd9051afa287295b Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Thu, 10 Sep 2009 11:14:47 +1000 Subject: Fix font glyph handling for QPF fonts in the OpenGL1 paint engine. Text drawing on OpenGL/ES 1.1 systems using QPF was displaying filled boxes in place of the character glyphs. This is due to the QPF implementation of alphaMapForGlyph() returning a different color table than that expected by QGLGlyphCache::cacheGlyphs(). Reviewed-by: Sarah Smith --- src/opengl/qpaintengine_opengl.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/opengl/qpaintengine_opengl.cpp b/src/opengl/qpaintengine_opengl.cpp index 86653eb..ff00f29 100644 --- a/src/opengl/qpaintengine_opengl.cpp +++ b/src/opengl/qpaintengine_opengl.cpp @@ -4790,7 +4790,24 @@ void QGLGlyphCache::cacheGlyphs(QGLContext *context, const QTextItemInt &ti, } } - QImage glyph_im(ti.fontEngine->alphaMapForGlyph(glyphs[i]).convertToFormat(QImage::Format_Indexed8)); + QImage glyph_im(ti.fontEngine->alphaMapForGlyph(glyphs[i])); + + // The QPF implementation of alphaMapForGlyph() uses the color + // RGBA = (value, value, value, 255) instead of the color + // RGBA = (0, 0, 0, value) that the other font engines use. + // We modify the image colors to rectify this situation. + QFontEngine::Type type = ti.fontEngine->type(); + if (type == QFontEngine::QPF1 || type == QFontEngine::QPF2) { + if (glyph_im.format() == QImage::Format_Indexed8) { + for (int i = 0; i < 256; ++i) + glyph_im.setColor(i, qRgba(0, 0, 0, i)); + } else if (glyph_im.format() == QImage::Format_Mono) { + glyph_im.setColor(0, qRgba(0, 0, 0, 0)); + glyph_im.setColor(1, qRgba(0, 0, 0, 255)); + } + } + + glyph_im = glyph_im.convertToFormat(QImage::Format_Indexed8); glyph_width = glyph_im.width(); Q_ASSERT(glyph_width >= 0); // pad the glyph width to an even number -- cgit v0.12