diff options
author | Florian Hänel <florian.haenel@basyskom.com> | 2012-09-28 15:00:48 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2012-12-12 10:47:48 +0100 |
commit | f65c85c004b6413d30fb438f3874f706f4d8ed9c (patch) | |
tree | 67aa1e310a10d4f01b0c3957bc17c53c8037ec46 /src/gui/text | |
parent | 968b11737564572ef5939400ed70f281556d167b (diff) |
FreeType bitmaps interpreted in wrong format
We ask grayscale or mono bitmaps from FreeType but in some cases treat
the output as ARGB without conversion. This surfaces using QGLWidget as
a viewport to QDeclarative content. The offending glyphs are then
generated through QTextureGlyphCache::textureMapForGlyph. This adds a
fix for converting to the expected ARGB32 data.
Change-Id: Ia219582ebd76b7e4e9379111a42312b4d97718de
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@digia.com>
Diffstat (limited to 'src/gui/text')
-rw-r--r-- | src/gui/text/qfontengine_ft.cpp | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/gui/text/qfontengine_ft.cpp b/src/gui/text/qfontengine_ft.cpp index fe72df64bd..af458c11a2 100644 --- a/src/gui/text/qfontengine_ft.cpp +++ b/src/gui/text/qfontengine_ft.cpp @@ -588,6 +588,16 @@ static void convertRGBToARGB_V(const uchar *src, uint *dst, int width, int heigh } } +static void convertGRAYToARGB(const uchar *src, uint *dst, int width, int height, int src_pitch) { + for (int y = 0; y < height; ++y) { + int readpos = (y * src_pitch); + int writepos = (y * width); + for (int x = 0; x < width; ++x) { + dst[writepos + x] = (0xFF << 24) + (src[readpos + x] << 16) + (src[readpos + x] << 8) + src[readpos + x]; + } + } +} + static void convoluteBitmap(const uchar *src, uchar *dst, int width, int height, int pitch) { // convolute the bitmap with a triangle filter to get rid of color fringes @@ -1016,7 +1026,7 @@ QFontEngineFT::Glyph *QFontEngineFT::loadGlyph(QGlyphSet *set, uint glyph, bitmap.rows = info.height*vfactor; bitmap.width = hpixels; bitmap.pitch = format == Format_Mono ? (((info.width + 31) & ~31) >> 3) : ((bitmap.width + 3) & ~3); - if (!hsubpixel && vfactor == 1) + if (!hsubpixel && vfactor == 1 && format != Format_A32) bitmap.buffer = glyph_buffer; else bitmap.buffer = new uchar[bitmap.rows*bitmap.pitch]; @@ -1047,6 +1057,8 @@ QFontEngineFT::Glyph *QFontEngineFT::loadGlyph(QGlyphSet *set, uint glyph, delete [] convoluted; } else if (vfactor != 1) { convertRGBToARGB_V(bitmap.buffer, (uint *)glyph_buffer, info.width, info.height, bitmap.pitch, subpixelType != QFontEngineFT::Subpixel_VRGB, true); + } else if (format == Format_A32 && bitmap.pixel_mode == FT_PIXEL_MODE_GRAY) { + convertGRAYToARGB(bitmap.buffer, (uint *)glyph_buffer, info.width, info.height, bitmap.pitch); } if (bitmap.buffer != glyph_buffer) |