[cairo] Win + Cario + SVG

Carl Worth cworth at cworth.org
Thu Nov 16 21:04:32 PST 2006


On Thu, 16 Nov 2006 20:29:40 -0800 (PST), Simon Flannery wrote:
> I would like to know if it is possible to load and render (dispaly
> to the sreeen/rendering-context) a simple svg file using Cairo with
> Windows XP. And if yes, then is there a MS VS C++ .NET (2003 / 2005)
> sample project setup and ready to download? I have Cairo setup and
> compiling, but the only function I can see for SVG file i/o is
> cairo_svg_surface_create which ONLY creates a file and does not
> render it!

What you are wanting should be possible, but not with cairo alone. I
don't do any programming on Windows, so I don't know about any project
already setup and ready to go. As for cairo itself, you've found
what's available, (that it can draw _to_ an SVG file, but not parse
data _from_ an SVG file).

> I also found this snippent of code:
>
> svg_cairo_t  *svgc;
> unsigned int  w, h;
> snippet_normalize (cr, width, height);
> svg_cairo_create (&svgc);
> svg_cairo_parse (svgc, "data/home.svg");
> svg_cairo_get_size (svgc, &w, &h);
> cairo_scale (cr, 1.0/w, 1.0/h);
> svg_cairo_render (svgc, cr);
> svg_cairo_destroy (svgc);

This snippet of code is using the libsvg-cairo library which builds on
top of cairo, (we really should pull this snippet off of the cairo web
site).

So, the libsvg-cairo does exist and it's probably not any harder to
build than cairo itself, (you would need the libsvg library too). You
can give that a try if you want, BUT...

The libsvg-cairo library is entirely unmaintained and likely to stay
that way. It began as a fork of the librsvg library to do SVG parsing
and rendering with cairo. But since then, librsvg developed
cairo-based rendering of its own. And librsvg is maintained and more
featureful.

So I recommend you look at librsvg instead. It's really not much
harder to use, (something like rsvg_handle_render_cairo instead of
svg_cairo_render in the above). Librsvg does have more dependencies
than libsvg-cairo, but that's probably offset by the fact that you can
probably find ready-built libraries for it for your platform of
interest.

Good luck, and have fun with cairo,

-Carl
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.freedesktop.org/archives/cairo/attachments/20061116/19483646/attachment.pgp


More information about the cairo mailing list