From dc6c26366727b85f9b28c50da3a75a653e37c5d8 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Mon, 19 Oct 2020 12:14:42 +0200 Subject: [PATCH] Fix output with box font engine The box font engine was passing in alpha values in the blue channel instead of alpha channel to QImage::setPixel(), probably assuming that setPixel() accepts the input in the format of the QImage. But the whole point of setPixel() is that it converts the input. If we just want to set the alpha value, we can do it directly on the QImage::bits(). [ChangeLog][Text] Fixed showing boxes for glyphs when there are no fonts available in the font database. Pick-to: 5.15 Change-Id: I7ae067c26b9ecba6aaa046e7e4b9ae520c4b3d23 Reviewed-by: Allan Sandfeld Jensen --- src/gui/text/qfontengine.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/gui/text/qfontengine.cpp b/src/gui/text/qfontengine.cpp index 15036718c3..9dd59e58f9 100644 --- a/src/gui/text/qfontengine.cpp +++ b/src/gui/text/qfontengine.cpp @@ -1670,12 +1670,12 @@ QImage QFontEngineBox::alphaMapForGlyph(glyph_t) QImage image(_size, _size, QImage::Format_Alpha8); image.fill(0); - // FIXME: use qpainter + uchar *bits = image.bits(); for (int i=2; i <= _size-3; ++i) { - image.setPixel(i, 2, 255); - image.setPixel(i, _size-3, 255); - image.setPixel(2, i, 255); - image.setPixel(_size-3, i, 255); + bits[i + 2 * image.bytesPerLine()] = 255; + bits[i + (_size - 3) * image.bytesPerLine()] = 255; + bits[2 + i * image.bytesPerLine()] = 255; + bits[_size - 3 + i * image.bytesPerLine()] = 255; } return image; }