/* Close the device */ static int svg_close_device(gx_device *dev) { gx_device_svg *const svg = (gx_device_svg*)dev; svg_write(svg, "\n<!-- svg_close_device -->\n"); /* close any open group elements */ while (svg->mark > 0) { svg_write(svg, "</g>\n"); svg->mark--; } if (svg->header) { svg_write(svg, "</svg>\n"); svg->header = 0; } if (svg->fillcolor) gs_free_string(svg->memory, (byte *)svg->fillcolor, 8, "svg_close_device"); if (svg->strokecolor) gs_free_string(svg->memory, (byte *)svg->strokecolor, 8, "svg_close_device"); if (ferror(svg->file)) return gs_throw_code(gs_error_ioerror); return gdev_vector_close_file((gx_device_vector*)dev); }
/* Complete a page */ static int svg_output_page(gx_device *dev, int num_copies, int flush) { gx_device_svg *const svg = (gx_device_svg*)dev; svg->page_count++; svg_write(svg, "\n<!-- svg_output_page -->\n"); if (ferror(svg->file)) return gs_throw_code(gs_error_ioerror); return gx_finish_output_page(dev, num_copies, flush); }
static int svg_setlinecap(gx_device_vector *vdev, gs_line_cap cap) { gx_device_svg *svg = (gx_device_svg *)vdev; const char *linecap_names[] = {"butt", "round", "square", "triangle", "unknown"}; if (cap < 0 || cap > gs_cap_unknown) return gs_throw_code(gs_error_rangecheck); if_debug1('_', "svg_setlinecap(%s)\n", linecap_names[cap]); svg->linecap = cap; svg->dirty++; return 0; }
static int svg_setlinejoin(gx_device_vector *vdev, gs_line_join join) { gx_device_svg *svg = (gx_device_svg *)vdev; const char *linejoin_names[] = {"miter", "round", "bevel", "none", "triangle", "unknown"}; if (join < 0 || join > gs_join_unknown) return gs_throw_code(gs_error_rangecheck); if_debug1('_', "svg_setlinejoin(%s)\n", linejoin_names[join]); svg->linejoin = join; svg->dirty++; return 0; }
/* Complete a page */ static int svg_output_page(gx_device *dev, int num_copies, int flush) { gx_device_svg *const svg = (gx_device_svg*)dev; int code; svg->page_count++; svg_write(svg, "\n<!-- svg_output_page -->\n"); if (ferror(svg->file)) return gs_throw_code(gs_error_ioerror); if ((code=gx_finish_output_page(dev, num_copies, flush)) < 0) return code; /* Check if we need to change the output file for separate pages */ if (gx_outputfile_is_separate_pages(((gx_device_vector *)dev)->fname, dev->memory)) { if ((code = svg_close_device(dev)) < 0) return code; code = svg_open_device(dev); } return code; }