[cairo] Observations from a newb
cworth at cworth.org
Thu Nov 8 08:50:28 PST 2007
On Thu, 8 Nov 2007 12:20:52 +0200, Donn wrote:
> > 1. ctx.draw_svg(<svg object>)
> > - librsvg is very good,has a liberal license and draws using cairo so
> > there is no need to duplicate.
> I can't get it to work. Would love to see what it does.
It provides exactly what you're asking for. The librsvg <svg object>
is called an RsvgHandle and you can create it with:
GError *error = NULL;
handle = rsvg_handle_new_from_file (filename, &error);
if (error != NULL)
and then render it to cairo with:
rsvg_handle_render_cairo (handle, cr);
So this part of your wishlist really is done already.
> > 2. Other image file formats - GIF,JPG
> > 3. cairo is not a font library
What you're asking for is basically just good integration with
higher-level libraries than cairo. For SVG, librsvg exists and is
integrated with cairo. For fonts, pango exists and is integrated with
For images, there are a number of different image-loading libraries,
many of which could use better integration with cairo. For example,
there's GdkPixbuf which is missing a tiny bit of functionality which
I've requested here:
Provide cairo convenience functions inside libgdkpixbuf
Other people on this mailing list have mentioned other libraries (PIL?
Devil?). I don't know anything about those, nor what level of cairo
integration they may or may not have.
> I don't quite understand that. Coming from the "Cairo draws stuff" pov again:
> images *are* stuff.
Sure. And cairo has a notion of them with cairo_image_surface_t and it
can definitely draw them. The "problem" only comes when you talk about
the dozens of different file formats that exist for storing images and
how to load those into a cairo_image_surface_t. That's definitely a
big task that's outside the scope of cairo itself.
> Yes, it's always amazed me that fonts on Gnu/Linux are so divorced from an
> actual font file!
It's really not that hard with cairo, in my opinion. You do have to
talk to the native font system, (freetype in the GNU/Linux case), but
that's not too surprising since you're doing a low-level "take this
custom font file" operation.
I think the only problem you ran into was a lack of python bindings
for freetype---not a limitation in cairo.
In general, it sounds like you'd be happy to see some
higher-level-than-cairo library that integrates cairo and several
other free software libraries. I think such libraries are a great
idea, and I encourage people to explore them[*]. A good library of
this sort would definitely not hide away the cairo API but would allow
the user to continue to use it for drawing things, (see the way GTK+
integrates cairo, for example).
You might want to look more closely at goocanvas or other similar
cairo-using libraries, as many of them do have some of the integration
you're looking for. They do also generally have some scene-graph level
of describing and manipulating objects which might be useful to you.
[*] Such a library shouldn't have a name like cairo-framework since
there are already a variety of different approaches to this kind of
thing, (the myriad of canvas libraries, for example), so I wouldn't
want to lend the name "cairo" to a single one of them.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 189 bytes
Desc: not available
Url : http://lists.cairographics.org/archives/cairo/attachments/20071108/0a261fb1/attachment.pgp
More information about the cairo