wasmhost: SVG icons with clip paths and masks (nanosvg drew them as black boxes)
CI / test (push) Failing after 18s

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DPL5hiNfjrw2edja7LiRLB
This commit is contained in:
Claude committed 2026-11-25 20:09:39 +00:00
1 parent b4b9ba0e10
commit 2774516abf
3 files changed
+262 -4

No files matched your search

+18
View File
@@ -0,0 +1,18 @@
# nanosvg
[nanosvg](https://github.com/memononen/nanosvg) (zlib licence, LICENSE.txt), used by the MoonBit
host (`wasmhost/bin/raster_stub.c`) to draw SVG icons. Upstream draws neither clip paths nor
masks: it drew their shapes, so many icon themes' icons came out with black boxes. Local changes
to `nanosvg.h`, all marked "Chandra":
- The shapes of a `<clipPath>` or `<mask>` are kept, flagged `NSVG_FLAGS_CLIP` (and
`NSVG_FLAGS_MASK`) with the clip's id in `clipOf`, and never drawn. A shape under
`clip-path` / `mask` names its clip in `clipId`.
- `nsvg__placeClips` moves each clip into the user space of the element using it.
- The content of `<symbol>`, `<pattern>`, `<marker>` and `<filter>` is skipped; a shape under
`filter="url(...)"` is flagged `NSVG_FLAGS_FILTERED`.
`nanosvgrast.h` is unchanged: `render_svg` in raster_stub.c draws runs of shapes and cuts
each to its clip's coverage (a mask's by luminance times alpha). On 370 icons from the Adwaita,
hicolor, Humanity and ubuntu-mono themes this matches resvg's rendering to within
anti-aliasing, except for a few icons that use luminance masks with filters.