From 9161a689f6da809f38133546540dc156b09fa7a1 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Thu, 16 Apr 2026 23:01:02 -0600 Subject: [PATCH] [vector] Increase paint fill/sweep radius from 32767 to 1000000 The SVG and PDF paint backends use large clipped rectangles to fill solid colors and gradient backgrounds. The old constant 32767 was sized for upem-space coordinates (~2048 max). After the pixel-space change, coordinates can be in font-scale (upem * SCALE, e.g. 131072 for a 2048-upem font at SCALE=64). Values above 32767 fell outside the fill rect, causing COLRv0 glyph layers to be clipped at the top. Bump all instances to 1000000 as a bandaid; proper fix is to emit paint coordinates in output-space. Regenerated vector test expected outputs. Assisted-by: Claude Opus 4.6 (1M context) --- src/hb-vector-paint-pdf.cc | 6 +++--- src/hb-vector-paint.cc | 8 ++++---- .../expected/basic/handwriting-cff-colr-1.svg | 18 +++++++++--------- .../expected/basic/handwriting-glyf-colr-1.svg | 18 +++++++++--------- 4 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/hb-vector-paint-pdf.cc b/src/hb-vector-paint-pdf.cc index 2ab5fb76f..d02819530 100644 --- a/src/hb-vector-paint-pdf.cc +++ b/src/hb-vector-paint-pdf.cc @@ -536,7 +536,7 @@ hb_pdf_paint_solid_color (hb_vector_paint_t *paint, hb_color_t c) hb_buf_append_str (&body, " rg\n"); /* Paint a huge rect (will be clipped). */ - hb_buf_append_str (&body, "-32767 -32767 65534 65534 re f\n"); + hb_buf_append_str (&body, "-1000000 -1000000 2000000 2000000 re f\n"); } static void @@ -1239,7 +1239,7 @@ hb_pdf_add_sweep_patch (hb_vector_t *mesh, float a0, hb_color_t c0_in, float a1, hb_color_t c1_in) { - const float R = 32767.f; + const float R = 1000000.f; const float eps = 0.5f; const float MAX_SECTOR = (float) M_PI / 2.f; @@ -1385,7 +1385,7 @@ hb_pdf_paint_sweep_gradient (hb_paint_funcs_t *, hb_paint_extend_t extend = hb_color_line_get_extend (color_line); - const float R = 32767.f; + const float R = 1000000.f; float xlo = cx - R - 1, xhi = cx + R + 1; float ylo = cy - R - 1, yhi = cy + R + 1; diff --git a/src/hb-vector-paint.cc b/src/hb-vector-paint.cc index 94c592e4e..69251c8e9 100644 --- a/src/hb-vector-paint.cc +++ b/src/hb-vector-paint.cc @@ -654,7 +654,7 @@ hb_vector_paint_color (hb_paint_funcs_t *, (unsigned) hb_color_get_alpha (paint->foreground) * hb_color_get_alpha (color) / 255); auto &body = paint->current_body (); - hb_buf_append_str (&body, "\n"); } @@ -766,7 +766,7 @@ hb_vector_paint_linear_gradient (hb_paint_funcs_t *, hb_buf_append_str (&paint->defs, "\n"); hb_buf_append_str (&paint->current_body (), - "current_body (), pfx, pfx_len); hb_buf_append_str (&paint->current_body (), "gr"); hb_buf_append_unsigned (&paint->current_body (), grad_id); @@ -831,7 +831,7 @@ hb_vector_paint_radial_gradient (hb_paint_funcs_t *, hb_buf_append_str (&paint->defs, "\n"); hb_buf_append_str (&paint->current_body (), - "current_body (), pfx, pfx_len); hb_buf_append_str (&paint->current_body (), "gr"); hb_buf_append_unsigned (&paint->current_body (), grad_id); @@ -863,7 +863,7 @@ hb_vector_paint_sweep_gradient (hb_paint_funcs_t *, float ga1 = start_angle + mx * (end_angle - start_angle); hb_vector_svg_sweep_ctx_t ctx { - &paint->current_body (), paint->precision, cx, cy, 32767.f + &paint->current_body (), paint->precision, cx, cy, 1000000.f }; hb_paint_sweep_gradient_tiles (stops.arrayZ, stops.length, hb_color_line_get_extend (color_line), diff --git a/test/vector/data/expected/basic/handwriting-cff-colr-1.svg b/test/vector/data/expected/basic/handwriting-cff-colr-1.svg index 2c1efc041..d9af8f578 100644 --- a/test/vector/data/expected/basic/handwriting-cff-colr-1.svg +++ b/test/vector/data/expected/basic/handwriting-cff-colr-1.svg @@ -36,7 +36,7 @@ - + @@ -44,42 +44,42 @@ - + - + - + - + - + - + @@ -87,7 +87,7 @@ - + @@ -95,7 +95,7 @@ - + diff --git a/test/vector/data/expected/basic/handwriting-glyf-colr-1.svg b/test/vector/data/expected/basic/handwriting-glyf-colr-1.svg index 4050cc41b..029ec3802 100644 --- a/test/vector/data/expected/basic/handwriting-glyf-colr-1.svg +++ b/test/vector/data/expected/basic/handwriting-glyf-colr-1.svg @@ -36,7 +36,7 @@ - + @@ -44,42 +44,42 @@ - + - + - + - + - + - + @@ -87,7 +87,7 @@ - + @@ -95,7 +95,7 @@ - +