From 612e9967800448ff5ac4cf26fdca5f4eaa3f3b63 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Tue, 24 Feb 2026 10:07:06 -0300 Subject: [PATCH] [hb-vector] Apply foreground color to draw output --- util/vector-output.hh | 39 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 36 insertions(+), 3 deletions(-) diff --git a/util/vector-output.hh b/util/vector-output.hh index e1cbbaa5e..04ae7e3a5 100644 --- a/util/vector-output.hh +++ b/util/vector-output.hh @@ -282,9 +282,9 @@ struct vector_output_t : output_options_t<> paint_blob && paint_blob != hb_blob_get_empty ()) write_combined_svg (draw_blob, paint_blob); else if (paint_blob && paint_blob != hb_blob_get_empty ()) - write_blob (paint_blob); + write_blob (paint_blob, false); else if (draw_blob && draw_blob != hb_blob_get_empty ()) - write_blob (draw_blob); + write_blob (draw_blob, true); hb_blob_destroy (draw_blob); hb_blob_destroy (paint_blob); @@ -512,7 +512,31 @@ struct vector_output_t : output_options_t<> return true; } - void write_blob (hb_blob_t *blob) + void emit_fill_group_open () + { + if (!foreground_str) + return; + + unsigned r = hb_color_get_red (foreground); + unsigned g = hb_color_get_green (foreground); + unsigned b = hb_color_get_blue (foreground); + unsigned a = hb_color_get_alpha (foreground); + + fprintf (out_fp, "\n"); + } + + void emit_fill_group_close () + { + if (!foreground_str) + return; + fputs ("\n", out_fp); + } + + void write_blob (hb_blob_t *blob, + hb_bool_t is_draw_blob) { unsigned in_len = 0; const char *in_data = hb_blob_get_data (blob, &in_len); @@ -539,8 +563,15 @@ struct vector_output_t : output_options_t<> emit_background_rect (); + if (is_draw_blob) + emit_fill_group_open (); + if (body.len) fwrite (body.p, 1, body.len, out_fp); + + if (is_draw_blob) + emit_fill_group_close (); + fputs ("\n", out_fp); } @@ -578,8 +609,10 @@ struct vector_output_t : output_options_t<> emit_background_rect (); + emit_fill_group_open (); if (draw_body.len) fwrite (draw_body.p, 1, draw_body.len, out_fp); + emit_fill_group_close (); if (paint_body.len) fwrite (paint_body.p, 1, paint_body.len, out_fp);