From 4e2a9b0c585d5c35675b73909be54faecde40481 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Fri, 17 Apr 2026 02:29:27 -0600 Subject: [PATCH] [vector/raster] Pass opaque foreground to paint_glyph The COLR walker's get_color bakes foreground_alpha into the returned color. Since our backends don't substitute paint->foreground in their callbacks (they trust the walker's resolved color), passing foreground with its own alpha would double-count it. Force alpha=255 when passing foreground to hb_font_paint_glyph and _or_fail, matching what cairo does. The backend applies foreground alpha through its own mechanisms (draw fill-opacity, raster compositing). Assisted-by: Claude Opus 4.6 (1M context) --- src/hb-raster-paint.cc | 4 ++-- src/hb-vector-paint.cc | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/hb-raster-paint.cc b/src/hb-raster-paint.cc index c4dde2ae6..60ebdf350 100644 --- a/src/hb-raster-paint.cc +++ b/src/hb-raster-paint.cc @@ -2252,11 +2252,11 @@ hb_raster_paint_glyph_impl (hb_raster_paint_t *paint, if (fallible) ret = hb_font_paint_glyph_or_fail (font, glyph, hb_raster_paint_get_funcs (paint), paint, - paint->palette, paint->foreground); + paint->palette, HB_COLOR (hb_color_get_blue (paint->foreground), hb_color_get_green (paint->foreground), hb_color_get_red (paint->foreground), 255)); else hb_font_paint_glyph (font, glyph, hb_raster_paint_get_funcs (paint), paint, - paint->palette, paint->foreground); + paint->palette, HB_COLOR (hb_color_get_blue (paint->foreground), hb_color_get_green (paint->foreground), hb_color_get_red (paint->foreground), 255)); hb_raster_paint_set_transform (paint, xx, yx, xy, yy, dx, dy); return ret; } diff --git a/src/hb-vector-paint.cc b/src/hb-vector-paint.cc index 42ed579e0..0287ca045 100644 --- a/src/hb-vector-paint.cc +++ b/src/hb-vector-paint.cc @@ -606,12 +606,12 @@ hb_vector_paint_glyph_impl (hb_vector_paint_t *paint, ret = hb_font_paint_glyph_or_fail (font, glyph, hb_vector_paint_pdf_funcs_get (), paint, (unsigned) paint->palette, - paint->foreground); + HB_COLOR (hb_color_get_blue (paint->foreground), hb_color_get_green (paint->foreground), hb_color_get_red (paint->foreground), 255)); else hb_font_paint_glyph (font, glyph, hb_vector_paint_pdf_funcs_get (), paint, (unsigned) paint->palette, - paint->foreground); + HB_COLOR (hb_color_get_blue (paint->foreground), hb_color_get_green (paint->foreground), hb_color_get_red (paint->foreground), 255)); body.append_str ("Q\n"); return ret; } @@ -646,12 +646,12 @@ hb_vector_paint_glyph_impl (hb_vector_paint_t *paint, ret = hb_font_paint_glyph_or_fail (font, glyph, hb_vector_paint_get_funcs (paint), paint, (unsigned) paint->palette, - paint->foreground); + HB_COLOR (hb_color_get_blue (paint->foreground), hb_color_get_green (paint->foreground), hb_color_get_red (paint->foreground), 255)); else hb_font_paint_glyph (font, glyph, hb_vector_paint_get_funcs (paint), paint, (unsigned) paint->palette, - paint->foreground); + HB_COLOR (hb_color_get_blue (paint->foreground), hb_color_get_green (paint->foreground), hb_color_get_red (paint->foreground), 255)); if (unlikely (!ret)) { paint->group_stack.pop ();