From d7d17ee055162fed9315ffbd7c645b2d83943a66 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Mon, 23 Feb 2026 22:30:07 -0300 Subject: [PATCH] raster: fix winding carry for edges left of the surface When an edge fell to the left of the rendering surface (col < 0), cell_add() discarded its winding contribution entirely. For glyphs whose outlines extend beyond the surface bounds (e.g. COLR v1 spliceMask clip glyphs), this caused the interior winding number to stay zero, producing empty rasterizations. Fix by forwarding the cover delta to column 0 so the left-to-right sweep picks up the correct accumulated winding. Co-Authored-By: Claude Opus 4.6 --- src/hb-raster-draw.cc | 12 ++++++++++++ src/hb-raster-paint.cc | 1 + 2 files changed, 13 insertions(+) diff --git a/src/hb-raster-draw.cc b/src/hb-raster-draw.cc index 48a018fe8..1010a971f 100644 --- a/src/hb-raster-draw.cc +++ b/src/hb-raster-draw.cc @@ -887,6 +887,18 @@ cell_add (int32_t *area, int16_t *cover, unsigned width, int col, int32_t fx0, int32_t fy0, int32_t fx1, int32_t fy1, int32_t wind, unsigned &x_min, unsigned &x_max) { + if (col < 0) + { + /* Edge is to the left of the surface. The winding contribution + * still carries into the visible region, so add the cover delta + * to column 0. Area is not added since the edge doesn't cross + * column 0's cell. */ + int32_t dy = fy1 - fy0; + cover[0] += (int16_t) (dy * wind); + x_min = hb_min (x_min, 0u); + x_max = hb_max (x_max, 0u); + return; + } if ((unsigned) col >= width) return; int32_t dy = fy1 - fy0; area[col] += (fx0 + fx1) * dy * wind; diff --git a/src/hb-raster-paint.cc b/src/hb-raster-paint.cc index 7fa661597..73eab8368 100644 --- a/src/hb-raster-paint.cc +++ b/src/hb-raster-paint.cc @@ -147,6 +147,7 @@ hb_raster_paint_push_clip_glyph (hb_paint_funcs_t *pfuncs HB_UNUSED, hb_font_draw_glyph (font, glyph, hb_raster_draw_get_funcs (), rdr); hb_raster_image_t *mask_img = hb_raster_draw_render (rdr); + if (unlikely (!mask_img)) { /* If mask rendering fails, push a fully transparent clip */