summaryrefslogtreecommitdiffstats
path: root/src/opengl
diff options
context:
space:
mode:
authorRhys Weatherley <rhys.weatherley@nokia.com>2009-09-10 01:14:47 (GMT)
committerRhys Weatherley <rhys.weatherley@nokia.com>2009-09-10 01:14:47 (GMT)
commitbaea4a79bc363e37970bcc24cd9051afa287295b (patch)
treebb73f98311529c17e8f32a5b02b5dd46b1b8c8e6 /src/opengl
parentad1db6e7046cc5bc1060c476abdfd92366f68edc (diff)
downloadQt-baea4a79bc363e37970bcc24cd9051afa287295b.zip
Qt-baea4a79bc363e37970bcc24cd9051afa287295b.tar.gz
Qt-baea4a79bc363e37970bcc24cd9051afa287295b.tar.bz2
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
Diffstat (limited to 'src/opengl')
-rw-r--r--src/opengl/qpaintengine_opengl.cpp19
1 files changed, 18 insertions, 1 deletions
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