Reputation: 4911
Is there a way to load an SVG from file and then render it to a Cairo canvas? Ideally something like:
image = read_from_svg("my.svg")
set_source_surface(cr, image, 0, 0)
paint(cr)
Upvotes: 1
Views: 901
Reputation: 2097
There is the Rsvg.jl package that wraps the rsvg library. The package can be installed with Pkg.add("Rsvg")
. You might have to troubleshoot the installation of the native Cairo and Rsvg libraries -- the package will attempt to do this automatically, but it is a difficult problem based on the multitude of different configurations.
Using that package, it seems be possible to do what you want. From the package's README:
using Rsvg
using Cairo
filename_in = "a4.svg"
r = Rsvg.handle_new_from_file(filename_in);
d = Rsvg.handle_get_dimensions(r);
cs = Cairo.CairoImageSurface(d.width,d.height,Cairo.FORMAT_ARGB32);
c = Cairo.CairoContext(cs);
Rsvg.handle_render_cairo(c,r);
Upvotes: 2