Open yisibl opened 3 years ago
Skia doesn't have anything built-in that allows you to load SVG files. I'd been looking into options such as canvg or fabric.js’s SVG parser on the Javascript side or µsvg to do the parsing in Rust.
But either way, it's a pretty big subproject on its own. If anyone felt like kicking the tires on one or more of those possibilities it's be a real help.
How do we convert the text in this SVG into a path?
If you just want to convert some text to a path (and don’t need to extract it from a SVG file), you can use the outlineText() method. It works just like fillText() and strokeText() but returns a Path2D object instead of drawing to the canvas.
In Skia, there is all the SVG rendering logic here: https://github.com/google/skia/tree/main/modules/svg/src
Neat, I didn't realize they’d added parsing to the SVG module. At the moment, rust-skia only supports generating SVG output from a canvas (not loading SVG files to be rendered) but I've filed a feature request. We’ll just have to wait and see…
Looks like rust-skia implemented the necessary bindings in https://github.com/rust-skia/rust-skia/pull/681 couple of months ago. Is there anything else blocking SVG file loading in skia-canvas?
I suppose one issue is that SVG support is on a separate type, as well as that SVG needs to have target width and height before being rasterized, which makes it quite different from other images in terms of storage.
Is it currently not supported to load an SVG file?
How do we convert the text in this SVG into a path?