[cairo] Cairo and SVG not working

Snider, Charles J cjsnide at sandia.gov
Thu Dec 9 09:24:23 PST 2010


I am having problems building SVG with an older version of Cairo (1.2.4), and I'd like to see if anyone can help me figure out why.

I have two servers that I am trying to build SVG files from, both using cairo, but different versions.
Server 1 -
Ubuntu 9.04, x windows
Cairo 1.8.8
Librsvg 2.26

Server 2 -
RHEL5 (red hat), headless
Cairo 1.2.4
Librsvg 2.16

On server 1, everything works fine with the sample code (CODE SAMPLE 1) below.
On server 2, the svg output looks like the second code sample (CODE SAMPLE 2) below.
It's just a skeleton of an svg file. But the strange thing is that the width and height are filled into the svg output, but nothing else.

Looking through past changelogs and such, cairo 1.2.4 should support SVG file output.
Is there something I could be missing that would cause server 2 to only partially work?

I can not find a good list of required dependencies for SVG to work in cairo 1.2.4.
It worked out of the box with cairo 1.8.8.

I, unfortunately, have no option to upgrade the version of cairo on server 2.

Anybody have any ideas at all, every bit helps, and thank you in advance,

(see code below)

- Charlie



################### BEGIN CODE SAMPLE 1 ###################
#include <cairo.h>
#include <cairo-svg.h>

int main() {

  cairo_surface_t *surface;
  cairo_t *cr;

  surface = cairo_svg_surface_create("svgfile.svg", 390, 60);
  cr = cairo_create(surface);

  cairo_set_source_rgb(cr, 0, 0, 0);
  cairo_select_font_face (cr, "Sans", CAIRO_FONT_SLANT_NORMAL,
      CAIRO_FONT_WEIGHT_NORMAL);
  cairo_set_font_size (cr, 40.0);

  cairo_move_to(cr, 10.0, 50.0);
  cairo_show_text(cr, "Hello.");

  cairo_surface_destroy(surface);
  cairo_destroy(cr);

  return 0;
}
################### END  CODE SAMPLE 1 ###################


################### BEGIN CODE SAMPLE 2 ###################
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="390pt" height="60pt" viewBox="0 0 390 60" version="1.1">
<defs>
<clipPath id="clip0">
  <rect width="390" height="60"/>
</clipPath>
</defs>
<g id="surface0" clip-path="url(#clip0)">
</g>
</svg>
################### END   CODE SAMPLE 2 ###################



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cairographics.org/archives/cairo/attachments/20101209/d5a301fd/attachment.html>


More information about the cairo mailing list