From 62c7fcd836a78599a772ba5dec4982e4cadd0cd3 Mon Sep 17 00:00:00 2001 From: Andi Gallo Date: Thu, 1 Jun 2023 07:04:39 +0000 Subject: [PATCH] LibGfx: Multiply alpha channels for vector fonts, when necessary When the background color has an alpha < 255, we can't copy over the pixel alpha. --- Userland/Libraries/LibGfx/Painter.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Userland/Libraries/LibGfx/Painter.cpp b/Userland/Libraries/LibGfx/Painter.cpp index cec2980fe0..51cc01e099 100644 --- a/Userland/Libraries/LibGfx/Painter.cpp +++ b/Userland/Libraries/LibGfx/Painter.cpp @@ -1430,6 +1430,10 @@ FLATTEN void Painter::draw_glyph(FloatPoint point, u32 code_point, Font const& f FloatRect rect(point.x(), point.y(), scaled_width, scaled_height); draw_scaled_bitmap(rect.to_rounded(), *glyph.bitmap(), glyph.bitmap()->rect(), 1.0f, ScalingMode::BilinearBlend); + } else if (color.alpha() != 255) { + blit_filtered(glyph_position.blit_position, *glyph.bitmap(), glyph.bitmap()->rect(), [color](Color pixel) -> Color { + return pixel.multiply(color); + }); } else { blit_filtered(glyph_position.blit_position, *glyph.bitmap(), glyph.bitmap()->rect(), [color](Color pixel) -> Color { return color.with_alpha(pixel.alpha());