<div dir="ltr"><div>Hi all,</div><div><br></div><div>I am having an issue with replaying a recording surface onto an SVG surface.  A minimal example is included at the end of the email.</div><div><br></div><div>Briefly, the example sets up a recording surface and two 100x100 surfaces -- one IMAGE and one SVG.  It then draws a 10x10 rectangle on each of them at position (10, 10) and saves the results (the IMAGE to a PNG).  Both resulting files display the box at the correct position.</div><div><br></div><div>The example then tries to replay the recording surface onto a separate 100x100 SVG surface, and also save that surface.  Unfortunately, this results in a blank SVG.  Note that if, instead, the recording surface is played onto a separate 100x100 IMAGE surface (code not included for simplicity), this works perfectly well (the resulting PNG also displays the box); so the basic setup of the recording surface seems correct.</div><div><br></div><div>I am using cairo 1.15.8 from Arch Linux.</div><div><br></div><div>Any help would be very welcome.  Thanks!</div><div><br></div><div>Antony Lee</div><div><br></div><div><br></div><div><br></div><div>=== Example program; compile and run with:</div><div>    gcc main.c $(pkg-config --cflags --libs cairo) -o main && ./main</div><div><br></div><div>#include <stddef.h></div><div>#include <cairo/cairo.h></div><div>#include <cairo/cairo-svg.h></div><div><br></div><div>int main() {</div><div>  cairo_surface_t* rec_surf = cairo_recording_surface_create(CAIRO_CONTENT_COLOR_ALPHA, NULL);</div><div>  cairo_t* rec_ctx = cairo_create(rec_surf);</div><div><br></div><div>  cairo_surface_t* img_surf = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 100, 100);</div><div>  cairo_t* img_ctx = cairo_create(img_surf);</div><div><br></div><div>  cairo_surface_t* svg_surf = cairo_svg_surface_create("/tmp/test.svg", 100, 100);</div><div>  cairo_t* svg_ctx = cairo_create(svg_surf);</div><div><br></div><div>  cairo_t* ctxs[3] = {rec_ctx, img_ctx, svg_ctx};</div><div><br></div><div>  for (unsigned i = 0; i < 3; ++i) {</div><div>    cairo_rectangle(ctxs[i], 10, 10, 10, 10);</div><div>    cairo_fill(ctxs[i]);</div><div>  }</div><div><br></div><div>  // Dump image to png.</div><div>  cairo_surface_write_to_png(img_surf, "/tmp/test.png");</div><div><br></div><div>  // Transfer recording surface to SVG.</div><div>  cairo_surface_t* svg1_surf = cairo_svg_surface_create("/tmp/test1.svg", 100, 100);</div><div>  cairo_t* svg1_ctx = cairo_create(svg1_surf);</div><div>  cairo_set_source_surface(svg1_ctx, rec_surf, 0, 0);</div><div>  cairo_paint(svg1_ctx);</div><div><br></div><div>  // Done.</div><div>  for (unsigned i = 0; i < 3; ++i) {</div><div>    if (cairo_status(ctxs[i])) {</div><div>      return 1;</div><div>    }</div><div>  }</div><div>  cairo_surface_finish(svg_surf);</div><div>  cairo_surface_finish(svg1_surf);</div><div>  for (unsigned i = 0; i < 3; ++i) {</div><div>    cairo_surface_destroy(cairo_get_target(ctxs[i]));</div><div>    cairo_destroy(ctxs[i]);</div><div>  }</div><div>  cairo_surface_destroy(svg1_surf);</div><div>  cairo_destroy(svg1_ctx);</div><div>}</div></div>