From 0ba555a3d4f00a5d2909b0cf8720e04b8fe83ff0 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Sat, 31 Oct 2026 10:56:46 -0600 Subject: [PATCH] [cairo] Clear the path before the rectangle clip (#6530) hb_cairo_push_clip_rectangle() appended its rectangle to whatever path was already on the cairo_t, where the sibling clip callbacks (hb_cairo_push_clip_glyph, hb_cairo_push_clip_path_start) all start with cairo_new_path(). This became reachable once compositing operations were gated on the work budget: hb_cairo_fill_glyph() now only runs cairo_fill() when spend_paint() succeeds, so a budget-skipped fill leaves the glyph outline on the context unconsumed. cairo's current path is not part of the graphics state, so the enclosing cairo_save()/cairo_restore() does not clear it; the leftover outline survives into the next push_clip_rectangle(), and cairo_rectangle() then adds the clip box to that outline instead of to an empty path, clipping to their union. Call cairo_new_path() first, matching the other clip callbacks, so the rectangle clip is always exactly the requested box. Full test suite passes (277/277). Co-authored-by: Claude Opus 4.8 --- src/hb-cairo.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/src/hb-cairo.cc b/src/hb-cairo.cc index 09329c1f3..b8b61ef53 100644 --- a/src/hb-cairo.cc +++ b/src/hb-cairo.cc @@ -272,6 +272,7 @@ hb_cairo_push_clip_rectangle (hb_paint_funcs_t *pfuncs HB_UNUSED, cairo_t *cr = c->cr; cairo_save (cr); + cairo_new_path (cr); cairo_rectangle (cr, (double) xmin, (double) ymin, (double) (xmax - xmin), (double) (ymax - ymin));