Files
chandra/third_party/nanosvg/README.md
T
2026-11-25 20:09:39 +00:00

19 lines
1.1 KiB
Markdown

# 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.