21 #ifdef HAVE_PANGOCAIRO
23 #include <librsvg/rsvg.h>
25 #include <librsvg/rsvg-cairo.h>
27 #include <cairo/cairo-svg.h>
30 #define NUL_FILE "nul"
32 #define NUL_FILE "/dev/null"
42 rsvg_handle_close((RsvgHandle*)us->
data,
NULL);
47 RsvgHandle* rsvgh =
NULL;
48 guchar *fileBuf =
NULL;
61 if (us->
datafree == gvloadimage_rsvg_free)
62 rsvgh = (RsvgHandle*)(us->
data);
79 #if !GLIB_CHECK_VERSION (2, 36, 0)
86 rsvgh = rsvg_handle_new();
89 fprintf(stderr,
"rsvg_handle_new_from_file returned an error: %s\n", err->message);
102 fileSize = stbuf.st_size;
104 fileBuf = calloc(fileSize + 1,
sizeof(guchar));
106 if (fileBuf ==
NULL) {
107 #if HAVE_G_OBJECT_UNREF
108 g_object_unref(rsvgh);
110 rsvg_handle_free(rsvgh);
115 #ifndef HAVE_SVG_2_36
124 if ((result = fread(fileBuf, 1, fileSize, us->
f)) < fileSize) {
126 #if HAVE_G_OBJECT_UNREF
127 g_object_unref(rsvgh);
129 rsvg_handle_free(rsvgh);
134 #ifndef HAVE_SVG_2_36
141 if (rsvg_handle_write(rsvgh, (
const guchar *)fileBuf, (gsize)fileSize, &err) ==
FALSE) {
142 fprintf(stderr,
"rsvg_handle_write returned an error: %s\n", err->message);
144 #if HAVE_G_OBJECT_UNREF
145 g_object_unref(rsvgh);
147 rsvg_handle_free(rsvgh);
152 #ifndef HAVE_SVG_2_36
161 rsvg_handle_close(rsvgh, &err);
170 us->
data = (
void*)rsvgh;
171 us->
datafree = gvloadimage_rsvg_free;
182 RsvgHandle* rsvgh = gvloadimage_rsvg_load(job, us);
184 cairo_t *cr = (cairo_t *) job->
context;
185 cairo_surface_t *surface;
190 surface = cairo_svg_surface_create(NUL_FILE, us->
w, us->
h);
192 cairo_surface_reference(surface);
194 cairo_set_source_surface(cr, surface, 0, 0);
195 cairo_translate(cr, b.
LL.
x, -b.
UR.
y);
196 cairo_scale(cr, (b.
UR.
x - b.
LL.
x)/(us->
w), (b.
UR.
y - b.
LL.
y)/(us->
h));
197 rsvg_handle_render_cairo(rsvgh, cr);
205 gvloadimage_rsvg_cairo
211 #ifdef HAVE_PANGOCAIRO
213 {FORMAT_SVG_CAIRO,
"svg:cairo", 1, &engine_cairo,
NULL},
void(* datafree)(usershape_t *us)
boolean gvusershape_file_access(usershape_t *us)
void gvusershape_file_release(usershape_t *us)
if(aagss+aagstacksize-1<=aagssp)
gvplugin_installed_t gvloadimage_rsvg_types[]