summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2019-09-08 13:56:58 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2019-09-25 14:46:36 +0200
commitd512f5ac3a53f7d153e9d1de8d3f468273bd7708 (patch)
treefcd6797f39ed78ab5b004c69116f20c778c2b6b8
parent70c053ee684448984b1f762abd3b40884cece2fa (diff)
Handle returned bitmap glyph when not requested
Add back code to handle bitmap glyphs returned when we did not request a bitmap glyph. This is a can happen on some configurations where bitmaps are not suppressed. Fixes: QTBUG-78116 Change-Id: Ie0c6cfbf9c50456431b0e3a23e568f3399e5a879 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
-rw-r--r--src/platformsupport/fontdatabases/freetype/qfontengine_ft.cpp30
1 files changed, 23 insertions, 7 deletions
diff --git a/src/platformsupport/fontdatabases/freetype/qfontengine_ft.cpp b/src/platformsupport/fontdatabases/freetype/qfontengine_ft.cpp
index 6011941982..8c6cc8fbc1 100644
--- a/src/platformsupport/fontdatabases/freetype/qfontengine_ft.cpp
+++ b/src/platformsupport/fontdatabases/freetype/qfontengine_ft.cpp
@@ -1110,16 +1110,32 @@ QFontEngineFT::Glyph *QFontEngineFT::loadGlyph(QGlyphSet *set, uint glyph,
glyph_buffer.reset(new uchar[glyph_buffer_size]);
if (slot->bitmap.pixel_mode == FT_PIXEL_MODE_MONO) {
- Q_ASSERT(format == Format_Mono);
uchar *src = slot->bitmap.buffer;
uchar *dst = glyph_buffer.data();
int h = slot->bitmap.rows;
-
- int bytes = ((info.width + 7) & ~7) >> 3;
- while (h--) {
- memcpy (dst, src, bytes);
- dst += pitch;
- src += slot->bitmap.pitch;
+ // Some fonts return bitmaps even when we requested something else:
+ if (format == Format_Mono) {
+ int bytes = ((info.width + 7) & ~7) >> 3;
+ while (h--) {
+ memcpy (dst, src, bytes);
+ dst += pitch;
+ src += slot->bitmap.pitch;
+ }
+ } else if (format == Format_A8) {
+ while (h--) {
+ for (int x = 0; x < int{info.width}; x++)
+ dst[x] = ((src[x >> 3] & (0x80 >> (x & 7))) ? 0xff : 0x00);
+ dst += pitch;
+ src += slot->bitmap.pitch;
+ }
+ } else {
+ while (h--) {
+ uint *dd = reinterpret_cast<uint *>(dst);
+ for (int x = 0; x < int{info.width}; x++)
+ dd[x] = ((src[x >> 3] & (0x80 >> (x & 7))) ? 0xffffffff : 0x00000000);
+ dst += pitch;
+ src += slot->bitmap.pitch;
+ }
}
} else if (slot->bitmap.pixel_mode == 7 /*FT_PIXEL_MODE_BGRA*/) {
Q_ASSERT(format == Format_ARGB);