[gs-cvs] rev 8730 - trunk/gs/src
giles at ghostscript.com
giles at ghostscript.com
Tue May 13 11:47:24 PDT 2008
Author: giles
Date: 2008-05-13 11:47:23 -0700 (Tue, 13 May 2008)
New Revision: 8730
Modified:
trunk/gs/src/gdevsvg.c
Log:
Disable drawing in the SVG output device after the first output_page call.
Even for single-page output we receive an erasepage fill after the showpage
from gdevvec, which overwrites whatever we've drawn. This should be avoided
in a more sophisticated way (ideally in the superclass) but this method is
helpful for current development.
Modified: trunk/gs/src/gdevsvg.c
===================================================================
--- trunk/gs/src/gdevsvg.c 2008-05-13 18:47:23 UTC (rev 8729)
+++ trunk/gs/src/gdevsvg.c 2008-05-13 18:47:23 UTC (rev 8730)
@@ -44,6 +44,7 @@
/* local state*/
int header;
int mark;
+ int page_count;
char *strokecolor, *fillcolor;
} gx_device_svg;
@@ -220,8 +221,9 @@
if (code < 0) return code;
/* svg-specific initialization goes here */
- svg->header = 0; /* file header hasn't been written */
- svg->mark = 0;
+ svg->header = 0; /* file header hasn't been written */
+ svg->mark = 0; /* have we drawn something? */
+ svg->page_count = 0;/* how many output_page calls we've seen */
svg->strokecolor = NULL;
svg->fillcolor = NULL;
@@ -234,8 +236,9 @@
{
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_error(gs_error_ioerror);
return gx_finish_output_page(dev, num_copies, flush);
@@ -393,7 +396,7 @@
svg_write_header(svg);
- dprintf("svg_beginpage\n");
+ dprintf1("svg_beginpage (page count %d)\n", svg->page_count);
return 0;
}
@@ -528,6 +531,8 @@
gx_device_svg *svg = (gx_device_svg *)vdev;
char line[300];
+ if (svg->page_count) return 0; /* hack single-page output */
+
dprintf1("svg_dorect (type %d)\n", type);
#if 0 /* dorect seems to be a duplicate? */
sprintf(line, "<rect x='%lf' y='%lf' width='%lf' height='%lf'/>\n",
@@ -543,6 +548,8 @@
{
gx_device_svg *svg = (gx_device_svg *)vdev;
+ if (svg->page_count) return 0; /* hack single-page output */
+
dprintf("svg_beginpath\n");
svg_write(svg, "<path d='");
@@ -556,6 +563,8 @@
gx_device_svg *svg = (gx_device_svg *)vdev;
char line[100];
+ if (svg->page_count) return 0; /* hack single-page output */
+
dprintf4("svg_moveto(%lf,%lf,%lf,%lf)\n", x0, y0, x, y);
sprintf(line, " M%lf,%lf", x, y);
@@ -571,6 +580,8 @@
gx_device_svg *svg = (gx_device_svg *)vdev;
char line[100];
+ if (svg->page_count) return 0; /* hack single-page output */
+
dprintf4("svg_lineto(%lf,%lf,%lf,%lf)\n", x0,y0, x,y);
sprintf(line, " L%lf,%lf", x, y);
@@ -587,6 +598,8 @@
gx_device_svg *svg = (gx_device_svg *)vdev;
char line[100];
+ if (svg->page_count) return 0; /* hack single-page output */
+
dprintf8("svg_curveto(%lf,%lf, %lf,%lf, %lf,%lf, %lf,%lf)\n",
x0,y0, x1,y1, x2,y2, x3,y3);
@@ -602,6 +615,8 @@
{
gx_device_svg *svg = (gx_device_svg *)vdev;
+ if (svg->page_count) return 0; /* hack single-page output */
+
dprintf("svg_closepath\n");
svg_write(svg, " z");
@@ -614,6 +629,8 @@
{
gx_device_svg *svg = (gx_device_svg *)vdev;
+ if (svg->page_count) return 0; /* hack single-page output */
+
dprintf("svg_endpath\n");
svg_write(svg, "'/>\n");
More information about the gs-cvs
mailing list