from Hacker News

Resvg- a fast, small, portable SVG rendering library in rust

by CyMonk on 6/12/22, 4:19 AM with 5 comments

  • by vlmutolo on 6/12/22, 12:21 PM

    This library's focus on correctness is what made me realize how absurdly complex SVG rendering is.

    They focus only on static SVG, and only on SVG 1 (though apparently they're working on SVG 2 support) and they still only manage to pass something like 90% of the tests.

    Which is more than any of the popular browsers or SVG rendering libraries. I wouldn't be surprised if resvg were the most compliant SVG renderer in existence.

    And that doesn't even take into account the actually complicated parts of SVG, like requiring an entire JavaScript interpreter for the <script> tags, which resvg rightfully excluded from its scope.

    These decisions made sense for the web, I guess, where all of the pieces were already there. The browsers already had to handle native text rendering, JavaScript, etc. It seems like SVG became something like a common interface to the drawing primitives browsers had anyway. Plus JavaScript.

    I'd like to see a much smaller, embeddable vector graphics format that doesn't require a whole browser to implement it.

  • by hirenj on 6/12/22, 3:12 PM

    I make use of a library in R to render SVG that uses Cairo to render to an intermediate (simplified) format, which looks a lot like what Resvg is doing with usvg. The advantage here seems to be that this is a much more compact library (fewer dependencies maybe?)

    Does anyone know if rust plays well acting as the backend for R libraries?

    How does this rendering/simplification compare with Cairo? I’m wondering if this is a fun summer project for some student!