mirror of
https://github.com/storytold/harfbuzz.git
synced 2026-11-22 15:31:05 +01:00
The GPU paint encoder left push_clip_rectangle at the no-op default while pop_clip unconditionally decremented clip_depth. COLR emits a rectangle push/pop pair around every PaintColrGlyph that has a ClipBox, so that pop removed whatever glyph/path clip sat below it on the stack. When such a PaintColrGlyph is nested inside a PaintGlyph, the sibling layers encoded afterwards carried one clip outline too few, painting ink outside the enclosing outline, or were dropped entirely when they reached an emitter with clip_depth == 0. Register a push_clip_rectangle callback that records the push in a small per-depth counter (rect_clips[d] = rectangles pushed while clip_depth was d). pop_clip consumes a non-zero count at the current depth first and only otherwise pops a real clip. Rectangle clips are still left unencoded, exactly as the v1 design notes state; the counter only keeps the glyph/path clip depth balanced across the ignored pair. This is correct for any LIFO push/pop order without allocation, and changes nothing for paint trees without rectangle clips (the top-level ClipBox in COLR::paint_glyph is already balanced). Reported by Anthropic's OSS Scanner as ordinary bug ANT-2026-ZEL64M07. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>