[cairo] Win + Cario + SVG

Simon Flannery simon_flannery at yahoo.com.au
Thu Nov 16 21:25:26 PST 2006


Thanks for the prompt reply.

I download and installed the GTK-dev from gladewin32.sourceforge.net/modules/news, version 2.10.6, which has all of cario, librsvg, etc as told from cariographics.org/download. I would like like to know how, and if it is possible, to render a SVG file to the sreen, then scale it etc... Has someone done this before? Any further advice? What am I missing?

Simon

----- Original Message ----
From: Carl Worth <cworth at cworth.org>
To: Simon Flannery <simon_flannery at yahoo.com.au>
Cc: cairo at cairographics.org
Sent: Friday, 17 November, 2006 4:04:32 PM
Subject: Re: [cairo] Win + Cario + SVG


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

Send instant messages to your online friends http://au.messenger.yahoo.com 


More information about the cairo mailing list