From 282e55dfa31bf10f0196bd191920ff37e9585b3d Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Fri, 17 Apr 2026 00:22:03 -0600 Subject: [PATCH] [vector-paint-pdf] Use paint's scratch path instead of stack draw_t MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit hb_pdf_emit_glyph_path was allocating a full hb_vector_draw_t on the stack (with its own heap-allocated buffers) just to emit one glyph path. Use paint->path (the existing scratch buffer) with the PDF path sink directly — no temporary draw context, no extra allocations. Assisted-by: Claude Opus 4.6 (1M context) --- src/hb-vector-paint-pdf.cc | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/hb-vector-paint-pdf.cc b/src/hb-vector-paint-pdf.cc index b813634cc..840f5a0d9 100644 --- a/src/hb-vector-paint-pdf.cc +++ b/src/hb-vector-paint-pdf.cc @@ -357,17 +357,13 @@ hb_pdf_emit_glyph_path (hb_vector_paint_t *paint, hb_codepoint_t glyph, hb_vector_t *buf) { - hb_vector_draw_t tmp; - tmp.format = HB_VECTOR_FORMAT_PDF; - tmp.set_precision (paint->get_precision ()); - tmp.transform = {1, 0, 0, 1, 0, 0}; - tmp.path.alloc (1024); - + hb_vector_path_sink_t sink = {&paint->path, paint->get_precision (), 1.f, 1.f}; + paint->path.clear (); hb_font_draw_glyph (font, glyph, - hb_vector_draw_get_funcs (&tmp), - &tmp); - - hb_buf_append_len (buf, tmp.path.arrayZ, tmp.path.length); + hb_vector_pdf_path_draw_funcs_get (), + &sink); + hb_buf_append_len (buf, paint->path.arrayZ, paint->path.length); + paint->path.clear (); }