[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) <noreply@anthropic.com>
This commit is contained in:
Behdad Esfahbod committed 2026-04-17 02:29:27 -06:00
1 parent e76163ebc8
commit 4e2a9b0c58
2 files changed
+6 -6

No files matched your search

+2 -2
View File
@@ -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;
}
+4 -4
View File
@@ -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 ();