From 81bbbc3fc47e47b9cd77248bbaaf35477f562895 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Fri, 7 Mar 2025 10:56:55 +0100 Subject: [PATCH] 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: 6.9 Fixes: QTBUG-134473 Change-Id: Iee7eb73a5727324e2ff3bacc2d9ae45cb64fd0b9 Reviewed-by: Eirik Aavitsland Reviewed-by: David Schulz (cherry picked from commit 54555755f8780e4e7c665a1502309da9fa807066) Reviewed-by: Qt Cherry-pick Bot --- src/gui/text/windows/qwindowsfontenginedirectwrite.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/gui/text/windows/qwindowsfontenginedirectwrite.cpp b/src/gui/text/windows/qwindowsfontenginedirectwrite.cpp index 791e17f1d69..34c0d1b4047 100644 --- a/src/gui/text/windows/qwindowsfontenginedirectwrite.cpp +++ b/src/gui/text/windows/qwindowsfontenginedirectwrite.cpp @@ -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) {