From: Friedrich Beckmann Date: Fri, 11 Sep 2020 16:32:13 +0000 (+0200) Subject: cairo: added xr_draw_svg_file function X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=93d2d30107990d531a64e1d704ccf9e3033a9c1b;p=pspp cairo: added xr_draw_svg_file function This is used by the output window to render the items for copy and paste. --- diff --git a/src/output/cairo.c b/src/output/cairo.c index 8c67ce03ae..b733c941fd 100644 --- a/src/output/cairo.c +++ b/src/output/cairo.c @@ -2253,3 +2253,23 @@ xr_render_output_item (struct xr_driver *xr, else return NULL; } + +bool +xr_draw_svg_file (struct xr_rendering *r, + const char *filename) +{ + int width, height; + g_assert (r); + xr_rendering_measure (r, &width, &height); + cairo_surface_t *surface = cairo_svg_surface_create (filename, width, height); + if (!surface) + { + g_error ("Could not create cairo svg surface with file %s", filename); + return FALSE; + } + cairo_t *cr = cairo_create (surface); + xr_rendering_draw (r, cr, 0, 0, width, height); + cairo_destroy (cr); + cairo_surface_destroy (surface); + return TRUE; +} diff --git a/src/output/cairo.h b/src/output/cairo.h index 4c32ca7ded..a13154b550 100644 --- a/src/output/cairo.h +++ b/src/output/cairo.h @@ -96,6 +96,9 @@ char *xr_draw_png_chart (const struct chart_item *, const struct cell_color *fg, const struct cell_color *bg); +/* Render to a svg file */ +bool xr_draw_svg_file (struct xr_rendering *r, + const char *filename); #endif /* HAVE_CAIRO */