[vector] Make paint_glyph use context palette and foreground

This commit is contained in:
Behdad Esfahbod committed 2026-02-24 19:20:49 -03:00
1 parent 75a1058ebb
commit 7d8c136fd5
4 files changed
+14 -18

No files matched your search

+8 -9
View File
@@ -2315,13 +2315,8 @@ hb_vector_paint_glyph (hb_vector_paint_t *paint,
hb_codepoint_t glyph,
float pen_x,
float pen_y,
hb_vector_extents_mode_t extents_mode,
unsigned palette,
hb_color_t foreground)
hb_vector_extents_mode_t extents_mode)
{
paint->palette = (int) palette;
paint->foreground = foreground;
float xx = paint->transform.xx;
float yx = paint->transform.yx;
float xy = paint->transform.xy;
@@ -2350,7 +2345,9 @@ hb_vector_paint_glyph (hb_vector_paint_t *paint,
hb_vector_paint_ensure_initialized (paint);
bool can_cache = !paint->flat;
hb_svg_color_glyph_cache_key_t cache_key = hb_svg_color_glyph_cache_key (glyph, palette, foreground);
hb_svg_color_glyph_cache_key_t cache_key = hb_svg_color_glyph_cache_key (glyph,
(unsigned) paint->palette,
paint->foreground);
if (can_cache)
{
if (paint->defined_color_glyphs.has (cache_key))
@@ -2392,7 +2389,8 @@ hb_vector_paint_glyph (hb_vector_paint_t *paint,
paint->current_face = hb_font_get_face (font);
hb_bool_t ret = hb_font_paint_glyph_or_fail (font, glyph,
hb_vector_paint_get_funcs (), paint,
palette, foreground);
(unsigned) paint->palette,
paint->foreground);
paint->current_svg_image_glyph = old_gid;
paint->current_face = old_face;
if (unlikely (!ret))
@@ -2452,7 +2450,8 @@ hb_vector_paint_glyph (hb_vector_paint_t *paint,
paint->current_face = hb_font_get_face (font);
hb_bool_t ret = hb_font_paint_glyph_or_fail (font, glyph,
hb_vector_paint_get_funcs (), paint,
palette, foreground);
(unsigned) paint->palette,
paint->foreground);
paint->current_svg_image_glyph = old_gid;
paint->current_face = old_face;
hb_svg_append_str (&body, "</g>\n");
+1 -5
View File
@@ -512,8 +512,6 @@ hb_vector_paint_get_funcs (void);
* @pen_x: glyph x origin before context transform.
* @pen_y: glyph y origin before context transform.
* @extents_mode: extents update mode.
* @palette: color palette index.
* @foreground: fallback foreground color.
*
* Paints one color glyph into @paint.
*
@@ -527,9 +525,7 @@ hb_vector_paint_glyph (hb_vector_paint_t *paint,
hb_codepoint_t glyph,
float pen_x,
float pen_y,
hb_vector_extents_mode_t extents_mode,
unsigned palette,
hb_color_t foreground);
hb_vector_extents_mode_t extents_mode);
/**
* hb_vector_svg_paint_set_flat:
+4 -2
View File
@@ -49,13 +49,15 @@ main (int argc, char **argv)
return 1;
}
hb_vector_paint_set_palette (paint, 0);
hb_vector_paint_set_foreground (paint, HB_COLOR (0, 0, 0, 255));
unsigned glyph_count = hb_face_get_glyph_count (face);
for (unsigned gid = 0; gid < glyph_count; gid++)
{
hb_vector_paint_set_transform (paint, 1.f, 0.f, 0.f, 1.f, 0.f, 0.f);
if (hb_vector_paint_glyph (paint, font, gid, 0.f, 0.f,
HB_VECTOR_EXTENTS_MODE_EXPAND,
0, HB_COLOR (0, 0, 0, 255)))
HB_VECTOR_EXTENTS_MODE_EXPAND))
{
hb_blob_t *blob = hb_vector_paint_render (paint);
hb_vector_paint_recycle_blob (paint, blob);
+1 -2
View File
@@ -262,8 +262,7 @@ struct vector_output_t : output_options_t<>
hb_vector_paint_set_transform (paint, 1.f, 0.f, 0.f, 1.f, 0.f, 0.f);
if (hb_vector_paint_glyph (paint, upem_font, g.gid, pen_x, pen_y,
extents_mode,
palette, foreground))
extents_mode))
{
had_paint = true;
continue;