treeform / pixie

Full-featured 2d graphics library for Nim.
MIT License
743 stars 28 forks source link

SVG compatibility fixes #337

Closed ehmry closed 2 years ago

treeform commented 2 years ago

Hello, thank you for the PR. What is this doing? Could you please describe the issue being fixed? Do you have an SVG file that shows the issue. Thanks!

ehmry commented 2 years ago

I was generating and rendering SVGs from NimSvg and their examples are not setting viewBox, which is fine according to the standard and many of the examples in the SVG spec are missing this. Without handling a missing viewBox attribute Pixie will fail to decode and give an opaque error.

I found another SVG with some RDF in a metadata element. I don't know what tool was used to generate it but metadata is also optional according to the spec.

The parseIntTuple proc is something I threw in to reduce string allocations during parsing.

treeform commented 2 years ago

Can you add some tests SVG files that can't be parse with current system. But your new system parses?

ehmry commented 2 years ago

I've looked at the SVG specs and its too complicated for me to work with. I tried to make some simple test images and Inkscape wouldn't even render them correctly. Sorry for the noisey PR :(