Using Cairo to render SVG in Enable

A few months ago Bryan Cole added the start of a Cairo based backend for Kiva. I’ve been fighting with Agg for several SVG related features and thought Cairo might be a good subsitute for rendering SVG’s. For most of our rendering needs, Cairo is about 4x slower than Agg, so its not a good general replacement, but for the SVG editor it might be okay. I took the initial work done, which only rendered to images, hacked it a bit, and go it into an Enable canvas. There is still a lot of work to be done, and this is the first time I’ve looked at Cairo at all, so if anyone wants to help out, please do. Anyway, without further ado, here is the SVG lion image:

Cairo rendered lion

If anyone knows how to get rid of the background rendering artifacts, please let me know.

5 thoughts on “Using Cairo to render SVG in Enable

  1. avatarBryan

    Glad to see someone’s interested in this. I’m hoping to get back to work on this in the New Year (the recent birth of a baby daughter has substantially reduced the time I can spend on this!).

    In fact, my next task is to add some “vectorised” methods to the pycairo API, to allow efficient drawing of polygons based on data from numpy arrays.

    When you say “Render SVGs”, do you mean you are reading in SVG files in to display on a cairo canvas (using librsvg), or simply writing to a cairo SVGSurface?


  2. avatarBryce

    What I am doing is using the SVG parser in the enthought.savage library, then using the parsed SVG to create the Cairo paths, text, etc. I then dump the Cairo GC’s data to a numpy array, which I massage, and blit in an Enable window.

  3. avatarBryce Hendrix

    Billy, you know where I can find any info on how to use glitz from Cairo? Is it just a surface I render to? Is it accessible from pycairo?

  4. avatarStu

    There is an open gl accelerated branch of Cairo being worked on – Cairo-gl. It’s probably going to take a little while to be ready, also there is ongoing work in Cairo on performance. Check the mailing lists for details.


Leave a Reply

Your email address will not be published. Required fields are marked *

Please leave these two fields as-is:

Protected by Invisible Defender. Showed 403 to 115,824 bad guys.