windows: Fix rendering monochrome glyphs in color fonts

If we encounter a normal, monochrome glyph in a color font, we
go via the normal glyph rendering code path. But since we are
drawing into a color-capable glyph cache, we need to make sure
the image we draw has an alpha channel.

This was inadvertedly broken by the refactoring in
1b85143d217042876209794bf8d0361b7ce8834f, causing black
backgrounds on all such glyphs. Since the default font in Qt Creator
is a color font, it was noticed when upgrading this to 6.9.

Pick-to: dev 6.9
Fixes: QTBUG-134473
Change-Id: Iee7eb73a5727324e2ff3bacc2d9ae45cb64fd0b9
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Eskil Abrahamsen Blomfeldt 2025-03-07 10:56:55 +01:00
parent 11f7ab988e
commit 54555755f8

View File

@ -1663,8 +1663,10 @@ QImage QWindowsFontEngineDirectWrite::imageForGlyph(glyph_t t,
// -1 due to Qt's off-by-one definition of a QRect
image = QImage(boundingRect.width() - 1,
boundingRect.height() - 1,
QImage::Format_RGB32);
image.fill(0xffffffff);
glyphFormat == QFontEngine::Format_ARGB
? QImage::Format_ARGB32_Premultiplied
: QImage::Format_RGB32);
image.fill(image.format() == QImage::Format_ARGB32_Premultiplied ? 0x0 : 0xffffffff);
float r, g, b, a;
if (glyphFormat == QFontEngine::Format_ARGB) {