[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 <noreply@anthropic.com>
This commit is contained in:
Behdad EsfahbodandClaude Opus 4.8 authored and GitHub committed 2026-10-31 10:56:46 -06:00
1 parent 7fde83a7e0
commit 0ba555a3d4
1 file changed
+1
+1
View File
@@ -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));