Revery: Ability to render SVG files

Created on 1 Oct 2019  路  7Comments  路  Source: revery-ui/revery

Would really like this feature, there are some nice SVG files I'd like to use but I'm having to convert them to png instead.

A-primitives enhancement skia-dependent

Most helpful comment

I was looking at something unrelated to this and stumbled upon this SVG rasterizing library: https://github.com/RazrFalcon/resvg. It even has minimal Skia bindings! Definitely something to consider. Writing an SVG renderer ourselves would be very time consuming!

All 7 comments

Ah ya, sorry @kyldvs - this is a major pain point at the moment!

Our work to integrate Skia (#567) will help here, as Skia has support for loading and rendering SVGs.

@bryphe now that Skia is in, is there an example of using SVG files? or do you have pointers about how I can try setting it up?

We need to create some module like Svg that define line, rect and cie. With the JSX syntax it will mean SVG has reason 馃檪 (maybe not the header)

Ya, unfortunately I was mistaken - SVG loading _is not_ built-in to Skia (although it provides all the drawing primitives we need to render them).

Flutter and Skiasharp actually have similar issues:

What we could do is bring in an XML parser (or a specific SVG one, like TyXml: http://ocsigen.org/tyxml/4.3.0/api/Svg_types) - and then, to render the SVG, traverse the document and render the paths/lines/rects/etc. We could limit ourselves to a small subset (ie, enough to get chess pieces rendering to start 馃槑 ). Although there are a lot that SVG supports, I think we could get by with a very small useful subset.

Additional capabilities could make for 'good first issues' once we have the infrastructure in place.

Alternatively, it looks like there are a few C/C++ libraries that could help:

I think what tricked me is there is an SkSVG class.... but it's for a canvas with a _SVG backend_, not for loading/parsing/rendering SVGs

I see, that makes sense! I'll continue to work around this for now and hold out a bit longer since it seems further out :)

I was looking at something unrelated to this and stumbled upon this SVG rasterizing library: https://github.com/RazrFalcon/resvg. It even has minimal Skia bindings! Definitely something to consider. Writing an SVG renderer ourselves would be very time consuming!

Was this page helpful?
0 / 5 - 0 ratings