At least for me, no SVG API is available as GObject API, so you have to deal with libxml2 library. On the other hand renderers are librsvg, but lacks API for SVG creation and Edition.

W3C has published an API specification version 1.1 for SVG and describes how renderers should interpret this XML document. W3C SVG depends on DOM as API to access XML documents.

While developing PLogic, I realized to have no way to create graphics for it, so take a look at GXml to dinamically generate SVG based on a logic diagram, using a GObject API to access XML documents. But no GObject API exists for SVG creation and edition.

Implement W3C API, is a matter to use OOP, like Java or C#, but a pain if you want to use pure C and GObject. So I choose Vala, because its syntaxis is very similar to W3C API and C#, making really easy to implement the API in a set of interfaces first and then in classes implementing those interfaces.

GXml lacks a good DOM support, due to liminations on libxml2 it relays on. So I started to implement a new pure GObject based set of classes, using libxml2 just for parsing and writting; they simple overcomes libxml2 limitations and now implements most DOM4,  whitout transformations.

GSVG now uses GXml’s GomNode classes series, improving time to implement features in W3C specifications.

GSVG have pushed GXml ahead, by exposing bugs and requesting new DOM4 implementations in order to provide useful SVG documents.

Author: despinosa

Linux and GNOME user, full time, since 2001. Actual maintainer of GXml and contributor to other projects mainly on GObject Introspection support.

4 thoughts on “Why GSVG”

    1. Cairo and librsvg, are the renderers. GSVG is the XML generator, so renderers will show you in the screen, create a PNG image or PDF file.

      1. If what you want is SVG/XML, you can use a Cairo SVG surface, draw your squares to it, and ask the surface to write itself to a file.

        cairo_surface_t *surf;
        cairo_t *cr;

        surf = cairo_svg_surface_create (“output.svg”, width, height);
        cr = cairo_create (surf);
        /* … draw to the cr … */

        1. A rich API to create and manipulate SVG provides more options for developers


          Here you can see a dynamically created SVG rendered by librsvg in a GtkImage, then it is modified and rendered again, you can see the effect.

          So being able to programmatically create vectorised drawings, can open new opportunities to create new things. One on my mind is to create scientific, medical or statistical graphs, based on SVG templates, while you get access using a rich W3C based API for SVG and DOM4 (this is why GSVG uses GXml, because SVG 1.1 requires DOM4).

          Your suggestion works, just it can’t stablish measurements in, i.e., millimeters and leave the renderer the hard work. When creating templates you can fill it with different data or adapt the drawing to different data or actions.

          Going farther, render a drawing on the fly when you manipulate and SVG, can reduce time expended, but that leaves librsvg out.

Leave a Reply

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