summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'media-gfx/inkscape/files/inkscape-20050326.psfix.patch')
-rw-r--r--media-gfx/inkscape/files/inkscape-20050326.psfix.patch1245
1 files changed, 1245 insertions, 0 deletions
diff --git a/media-gfx/inkscape/files/inkscape-20050326.psfix.patch b/media-gfx/inkscape/files/inkscape-20050326.psfix.patch
new file mode 100644
index 0000000..061a526
--- /dev/null
+++ b/media-gfx/inkscape/files/inkscape-20050326.psfix.patch
@@ -0,0 +1,1245 @@
+diff -urN inkscape-20050326-2100.orig/src/.kdbgrc.inkscape inkscape-20050326-2100/src/.kdbgrc.inkscape
+--- inkscape-20050326-2100.orig/src/.kdbgrc.inkscape 1970-01-01 01:00:00.000000000 +0100
++++ inkscape-20050326-2100/src/.kdbgrc.inkscape 2005-03-29 15:06:43.000000000 +0200
+@@ -0,0 +1,27 @@
++[Breakpoint 0]
++Enabled=true
++File=ps.cpp
++Line=298
++Temporary=false
++
++[Breakpoint 1]
++Enabled=true
++File=ps.cpp
++Line=249
++Temporary=false
++
++[General]
++DebuggerCmdStr=
++DriverName=GDB
++FileVersion=1
++OptionsSelected=
++ProgramArgs=--print \\>/tmp/foo.eps /home/pauldv/data/thesis/Chapter4/modelOverview.svg
++TTYLevel=7
++WorkingDirectory=
++
++[Memory]
++ColumnWidths=80,0
++NumExprs=0
++
++[Watches]
++Expr0=&fn[strlen(fn)-4]
+diff -urN inkscape-20050326-2100.orig/src/extension/internal/Makefile_insert inkscape-20050326-2100/src/extension/internal/Makefile_insert
+--- inkscape-20050326-2100.orig/src/extension/internal/Makefile_insert 2005-03-27 07:01:06.000000000 +0200
++++ inkscape-20050326-2100/src/extension/internal/Makefile_insert 2005-03-29 13:59:42.000000000 +0200
+@@ -16,6 +16,8 @@
+ extension/internal/svg.cpp \
+ extension/internal/svgz.h \
+ extension/internal/svgz.cpp \
++ extension/internal/pstree.h \
++ extension/internal/pstree.cpp \
+ extension/internal/ps.h \
+ extension/internal/ps.cpp \
+ extension/internal/ps-out.h \
+diff -urN inkscape-20050326-2100.orig/src/extension/internal/ps.cpp inkscape-20050326-2100/src/extension/internal/ps.cpp
+--- inkscape-20050326-2100.orig/src/extension/internal/ps.cpp 2005-03-27 07:01:06.000000000 +0200
++++ inkscape-20050326-2100/src/extension/internal/ps.cpp 2005-03-29 15:04:51.000000000 +0200
+@@ -74,6 +74,9 @@
+
+ #include "io/sys.h"
+
++using namespace std;
++using namespace Inkscape::Extension::Internal::PS;
++
+ namespace Inkscape {
+ namespace Extension {
+ namespace Internal {
+@@ -81,7 +84,8 @@
+ PrintPS::PrintPS() :
+ _stream(NULL),
+ _dpi(72),
+- _bitmap(false)
++ _bitmap(false),
++ _tree(0)
+ {
+ }
+
+@@ -239,13 +243,14 @@
+ unsigned int
+ PrintPS::begin(Inkscape::Extension::Print *mod, SPDocument *doc)
+ {
+- Inkscape::SVGOStringStream os;
+ int res;
+ FILE *osf, *osp;
+ const gchar * fn;
+
+ fn = mod->get_param_string("destination");
+
++ _tree.reset(new PSTree());
++
+ osf = NULL;
+ osp = NULL;
+
+@@ -256,6 +261,8 @@
+ -1, &bytesRead, &bytesWritten, &error);
+ fn = local_fn;
+
++ bool overridePageBB = false;
++
+ /* TODO: Replace the below fprintf's with something that does the right thing whether in
+ * gui or batch mode (e.g. --print=blah). Consider throwing an exception: currently one of
+ * the callers (sp_print_document_to_file, "ret = mod->begin(doc)") wrongly ignores the
+@@ -287,6 +294,12 @@
+ return 0;
+ }
+ _stream = osf;
++
++ // Hack to allow export to eps
++ if (strcasecmp(".eps",&fn[strlen(fn)-4])==0) {
++ overridePageBB=true;
++ }
++
+ } else {
+ gchar *qn;
+ /* put cwd stuff in here */
+@@ -316,6 +329,7 @@
+ #endif
+ }
+
++ // Don't put this in the tree to have sane error handling
+ res = fprintf(_stream, "%%!PS-Adobe-3.0\n");
+ /* flush this to test output stream as early as possible */
+ if (fflush(_stream)) {
+@@ -341,7 +355,7 @@
+ bool pageLandscape;
+ pageBoundingBox = mod->get_param_bool("pageBoundingBox");
+ // printf("Page Bounding Box: %s\n", pageBoundingBox ? "TRUE" : "FALSE");
+- if (pageBoundingBox) {
++ if (pageBoundingBox && (! overridePageBB )) {
+ d.x0 = d.y0 = 0;
+ d.x1 = ceil(_width);
+ d.y1 = ceil(_height);
+@@ -356,14 +370,13 @@
+ }
+
+ if (res >= 0) {
+-
+- os << "%%Creator: " << PACKAGE_STRING << "\n";
++ *_tree << "%%Creator: " << PACKAGE_STRING << "\n";
+ // This will become problematic if inkscape gains the
+ // ability to handle multi paged documents. If this is
+ // the case the %%Orientation: comments should be
+ // renamed to %%PageOrientation: and moved to the
+ // respective pages.
+- os << "%%Pages: 1\n";
++ *_tree << "%%Pages: 1\n";
+
+ // 2004 Dec 10, BFC:
+ // The point of the following code is (1) to do the thing that's expected by users
+@@ -383,8 +396,8 @@
+ }
+
+ if (pageLandscape) {
+- os << "%%Orientation: Landscape\n";
+- os << "%%BoundingBox: " << (int) (_height - d.y1) << " "
++ *_tree << "%%Orientation: Landscape\n";
++ *_tree << "%%BoundingBox: " << (int) (_height - d.y1) << " "
+ << (int) d.x0 << " "
+ << (int) ceil(_height - d.y0) << " "
+ << (int) ceil(d.x1) << "\n";
+@@ -395,44 +408,44 @@
+ // FIXME: I couldn't find HiResBoundingBox in the PS
+ // reference manual, so I guess we should skip
+ // it.
+- os << "%%HiResBoundingBox: " << (_height - d.y1) << " "
+- << d.x0 << " "
+- << (_height - d.y0) << " "
+- << d.x1 << "\n";
++ *_tree << "%%HiResBoundingBox: " << (_height - d.y1) << " "
++ << d.x0 << " "
++ << (_height - d.y0) << " "
++ << d.x1 << "\n";
+ } else {
+- os << "%%Orientation: Portrait\n";
+- os << "%%BoundingBox: " << (int) d.x0 << " "
++ *_tree << "%%Orientation: Portrait\n";
++ *_tree << "%%BoundingBox: " << (int) d.x0 << " "
+ << (int) d.y0 << " "
+ << (int) ceil(d.x1) << " "
+ << (int) ceil(d.y1) << "\n";
+- os << "%%HiResBoundingBox: " << d.x0 << " "
++ *_tree << "%%HiResBoundingBox: " << d.x0 << " "
+ << d.y0 << " "
+ << d.x1 << " "
+ << d.y1 << "\n";
+ }
+
+- os << "%%EndComments\n";
++ *_tree << "%%EndComments\n";
+ // This will become problematic if we print multi paged documents:
+- os << "%%Page: 1 1\n";
++ *_tree << "%%Page: 1 1\n";
+
+ if (pageLandscape) {
+- os << "90 rotate\n";
++ *_tree << "90 rotate\n";
+ if (_bitmap) {
+- os << "0 " << (int) -ceil(_height) << " translate\n";
++ *_tree << "0 " << (int) -ceil(_height) << " translate\n";
+ }
+ } else {
+ if (!_bitmap) {
+- os << "0 " << (int) ceil(_height) << " translate\n";
++ *_tree << "0 " << (int) ceil(_height) << " translate\n";
+ }
+ }
+
+ if (!_bitmap) {
+- os << PT_PER_PX << " " << -PT_PER_PX << " scale\n";
++ *_tree << PT_PER_PX << " " << -PT_PER_PX << " scale\n";
+ // from now on we can output px, but they will be treated as pt
+ }
+ }
+
+- return fprintf(_stream, "%s", os.str().c_str());
++ return 0; // wait with printing until finish;
+ }
+
+ unsigned int
+@@ -505,14 +518,18 @@
+ nr_free(px);
+ }
+
+- res = fprintf(_stream, "showpage\n");
++ *_tree << "showpage\n";
++
++ string s = _tree->str();
+
++ res=fprintf(_stream,"%s",s.c_str());
+ /* Flush stream to be sure. */
+ (void) fflush(_stream);
+
+ /* fixme: should really use pclose for popen'd streams */
+ fclose(_stream);
+ _stream = 0;
++ _tree.release();
+
+ return res;
+ }
+@@ -523,15 +540,15 @@
+ if (!_stream) return 0; // XXX: fixme, returning -1 as unsigned.
+ if (_bitmap) return 0;
+
+- Inkscape::SVGOStringStream os;
+- os << "gsave [" << transform->c[0] << " "
++ _tree->gsave();
++ *_tree << "[" << transform->c[0] << " "
+ << transform->c[1] << " "
+ << transform->c[2] << " "
+ << transform->c[3] << " "
+ << transform->c[4] << " "
+ << transform->c[5] << "] concat\n";
+
+- return fprintf(_stream, "%s", os.str().c_str());
++ return 0;
+ }
+
+ unsigned int
+@@ -539,8 +556,9 @@
+ {
+ if (!_stream) return 0; // XXX: fixme, returning -1 as unsigned.
+ if (_bitmap) return 0;
++ _tree->grestore();
+
+- return fprintf(_stream, "grestore\n");
++ return 0;
+ }
+
+ unsigned int
+@@ -549,108 +567,109 @@
+ if (!_stream) return 0; // XXX: fixme, returning -1 as unsigned.
+ if (_bitmap) return 0;
+
+- return fprintf(_stream, "%%! %s\n",comment);
++ *_tree << "%%! %s" << comment << "\n";
++ return 0;
+ }
+
+ void
+-PrintPS::print_fill_style(SVGOStringStream &os, const SPStyle *style)
++PrintPS::print_fill_style(const SPStyle *style)
+ {
+ g_return_if_fail(style->fill.type == SP_PAINT_TYPE_COLOR || SP_IS_GRADIENT (SP_STYLE_FILL_SERVER (style)));
+-
++
+ if (style->fill.type == SP_PAINT_TYPE_COLOR)
+ {
+ float rgb[3];
+ sp_color_get_rgb_floatv(&style->fill.value.color, rgb);
+
+- os << rgb[0] << " " << rgb[1] << " " << rgb[2] << " setrgbcolor\n";
++ *_tree << rgb[0] << " " << rgb[1] << " " << rgb[2] << " setrgbcolor\n";
+ } else if (SP_IS_GRADIENT (SP_STYLE_FILL_SERVER (style))) {
+ if (SP_IS_LINEARGRADIENT (SP_STYLE_FILL_SERVER (style))) {
+ SPLinearGradient *lg=SP_LINEARGRADIENT(SP_STYLE_FILL_SERVER (style));
+- os << "<<\n/ShadingType 2\n/ColorSpace /DeviceRGB\n";
+- os << "/Coords [" << lg->x1.computed << " " << lg->y1.computed << " " << lg->x2.computed << " " << lg->y2.computed <<"]\n";
+- os << "/Extend [true true]\n";
+- os << "/Domain [0 1]\n";
+- os << "/Function <<\n/FunctionType 3\n/Functions\n[\n";
++ *_tree << "<<\n/ShadingType 2\n/ColorSpace /DeviceRGB\n";
++ *_tree << "/Coords [" << lg->x1.computed << " " << lg->y1.computed << " " << lg->x2.computed << " " << lg->y2.computed <<"]\n";
++ *_tree << "/Extend [true true]\n";
++ *_tree << "/Domain [0 1]\n";
++ *_tree << "/Function <<\n/FunctionType 3\n/Functions\n[\n";
+ for (gint i=0;unsigned(i)<lg->vector.stops.size()-1;i++) {
+ float rgb[3];
+ sp_color_get_rgb_floatv(&lg->vector.stops[i].color, rgb);
+- os << "<<\n/FunctionType 2\n/Domain [0 1]\n";
+- os << "/C0 [" << rgb[0] << " " << rgb[1] << " " << rgb[2] << "]\n";
++ *_tree << "<<\n/FunctionType 2\n/Domain [0 1]\n";
++ *_tree << "/C0 [" << rgb[0] << " " << rgb[1] << " " << rgb[2] << "]\n";
+ sp_color_get_rgb_floatv(&lg->vector.stops[i+1].color, rgb);
+- os << "/C1 [" << rgb[0] << " " << rgb[1] << " " << rgb[2] << "]\n";
+- os << "/N 1\n>>\n";
++ *_tree << "/C1 [" << rgb[0] << " " << rgb[1] << " " << rgb[2] << "]\n";
++ *_tree << "/N 1\n>>\n";
+ }
+- os << "]\n/Domain [0 1]\n";
+- os << "/Bounds [ ";
++ *_tree << "]\n/Domain [0 1]\n";
++ *_tree << "/Bounds [ ";
+ for (gint i=0;unsigned(i)<lg->vector.stops.size()-2;i++) {
+- os << lg->vector.stops[i+1].offset <<" ";
++ *_tree << lg->vector.stops[i+1].offset <<" ";
+ }
+- os << "]\n";
+- os << "/Encode [ ";
++ *_tree << "]\n";
++ *_tree << "/Encode [ ";
+ for (gint i=0;unsigned(i)<lg->vector.stops.size()-1;i++) {
+- os << "0 1 ";
++ *_tree << "0 1 ";
+ }
+- os << "]\n";
+- os << ">>\n>>\n";
++ *_tree << "]\n";
++ *_tree << ">>\n>>\n";
+ } else if (SP_IS_RADIALGRADIENT (SP_STYLE_FILL_SERVER (style))) {
+ SPRadialGradient *rg=SP_RADIALGRADIENT(SP_STYLE_FILL_SERVER (style));
+- os << "<<\n/ShadingType 3\n/ColorSpace /DeviceRGB\n";
+- os << "/Coords ["<<rg->fx.computed<<" "<<rg->fy.computed<<" 0 "<<rg->cx.computed<<" "<<rg->cy.computed<<" "<<rg->r.computed<<"]\n";
+- os << "/Extend [true true]\n";
+- os << "/Domain [0 1]\n";
+- os << "/Function <<\n/FunctionType 3\n/Functions\n[\n";
++ *_tree << "<<\n/ShadingType 3\n/ColorSpace /DeviceRGB\n";
++ *_tree << "/Coords ["<<rg->fx.computed<<" "<<rg->fy.computed<<" 0 "<<rg->cx.computed<<" "<<rg->cy.computed<<" "<<rg->r.computed<<"]\n";
++ *_tree << "/Extend [true true]\n";
++ *_tree << "/Domain [0 1]\n";
++ *_tree << "/Function <<\n/FunctionType 3\n/Functions\n[\n";
+ for (gint i=0;unsigned(i)<rg->vector.stops.size()-1;i++) {
+ float rgb[3];
+ sp_color_get_rgb_floatv(&rg->vector.stops[i].color, rgb);
+- os << "<<\n/FunctionType 2\n/Domain [0 1]\n";
+- os << "/C0 [" << rgb[0] << " " << rgb[1] << " " << rgb[2] << "]\n";
++ *_tree << "<<\n/FunctionType 2\n/Domain [0 1]\n";
++ *_tree << "/C0 [" << rgb[0] << " " << rgb[1] << " " << rgb[2] << "]\n";
+ sp_color_get_rgb_floatv(&rg->vector.stops[i+1].color, rgb);
+- os << "/C1 [" << rgb[0] << " " << rgb[1] << " " << rgb[2] << "]\n";
+- os << "/N 1\n>>\n";
++ *_tree << "/C1 [" << rgb[0] << " " << rgb[1] << " " << rgb[2] << "]\n";
++ *_tree << "/N 1\n>>\n";
+ }
+- os << "]\n/Domain [0 1]\n";
+- os << "/Bounds [ ";
++ *_tree << "]\n/Domain [0 1]\n";
++ *_tree << "/Bounds [ ";
+ for (gint i=0;unsigned(i)<rg->vector.stops.size()-2;i++) {
+- os << rg->vector.stops[i+1].offset <<" ";
++ *_tree << rg->vector.stops[i+1].offset <<" ";
+ }
+- os << "]\n";
+- os << "/Encode [ ";
++ *_tree << "]\n";
++ *_tree << "/Encode [ ";
+ for (gint i=0;unsigned(i)<rg->vector.stops.size()-1;i++) {
+- os << "0 1 ";
++ *_tree << "0 1 ";
+ }
+- os << "]\n";
+- os << ">>\n>>\n";
++ *_tree << "]\n";
++ *_tree << ">>\n>>\n";
+ }
+ }
+ }
+
+ void
+-PrintPS::print_stroke_style(SVGOStringStream &os, const SPStyle *style)
++PrintPS::print_stroke_style(const SPStyle *style)
+ {
+ float rgb[3];
+ sp_color_get_rgb_floatv(&style->stroke.value.color, rgb);
+
+- os << rgb[0] << " " << rgb[1] << " " << rgb[2] << " setrgbcolor\n";
++ *_tree << rgb[0] << " " << rgb[1] << " " << rgb[2] << " setrgbcolor\n";
+
+ if (style->stroke_dasharray_set &&
+ style->stroke_dash.n_dash &&
+ style->stroke_dash.dash) {
+ int i;
+- os << "[";
++ *_tree << "[";
+ for (i = 0; i < style->stroke_dash.n_dash; i++) {
+ if ((i)) {
+- os << " ";
++ *_tree << " ";
+ }
+- os << style->stroke_dash.dash[i];
++ *_tree << style->stroke_dash.dash[i];
+ }
+- os << "] " << style->stroke_dash.offset << " setdash\n";
++ *_tree << "] " << style->stroke_dash.offset << " setdash\n";
+ } else {
+- os << "[] 0 setdash\n";
++ *_tree << "[] 0 setdash\n";
+ }
+
+- os << style->stroke_width.computed << " setlinewidth\n";
+- os << style->stroke_linejoin.computed << " setlinejoin\n";
+- os << style->stroke_linecap.computed << " setlinecap\n";
++ *_tree << style->stroke_width.computed << " setlinewidth\n";
++ *_tree << style->stroke_linejoin.computed << " setlinejoin\n";
++ *_tree << style->stroke_linecap.computed << " setlinecap\n";
+ }
+
+
+@@ -662,52 +681,53 @@
+ if (_bitmap) return 0;
+
+ if (style->fill.type == SP_PAINT_TYPE_COLOR || SP_IS_GRADIENT (SP_STYLE_FILL_SERVER (style))) {
+- Inkscape::SVGOStringStream os;
+
+- os << "gsave\n";
++ _tree->gsave();
+
+- print_fill_style(os, style);
++ print_fill_style(style);
+
+- print_bpath(os, bpath->path);
++ print_bpath(bpath->path);
+
+ if (style->fill_rule.value == SP_WIND_RULE_EVENODD) {
+ if (style->fill.type == SP_PAINT_TYPE_COLOR) {
+- os << "eofill\n";
++ *_tree << "eofill\n";
+ } else if (SP_IS_GRADIENT (SP_STYLE_FILL_SERVER (style))) {
+ SPGradient *g=SP_GRADIENT(SP_STYLE_FILL_SERVER (style));
+- os << "eoclip\n";
++ *_tree << "eoclip\n";
+ if (g->gradientTransform_set) {
+- os << "gsave [" << g->gradientTransform[0] << " " << g->gradientTransform[1]
+- << " " << g->gradientTransform[2] << " " << g->gradientTransform[3]
+- << " " << g->gradientTransform[4] << " " << g->gradientTransform[5] << "] concat\n";
++ _tree->gsave();
++ *_tree << "[" << g->gradientTransform[0] << " " << g->gradientTransform[1]
++ << " " << g->gradientTransform[2] << " " << g->gradientTransform[3]
++ << " " << g->gradientTransform[4] << " " << g->gradientTransform[5] << "] concat\n";
+ }
+- os << "shfill\n";
++ *_tree << "shfill\n";
+ if (g->gradientTransform_set) {
+- os << "grestore\n";
++ _tree->grestore();
+ }
+ }
+ } else {
+ if (style->fill.type == SP_PAINT_TYPE_COLOR) {
+- os << "fill\n";
++ *_tree << "fill\n";
+ } else if (SP_IS_GRADIENT (SP_STYLE_FILL_SERVER (style))) {
+ SPGradient *g=SP_GRADIENT(SP_STYLE_FILL_SERVER (style));
+- os << "clip\n";
++ *_tree << "clip\n";
+ if (g->gradientTransform_set) {
+- os << "gsave [" << g->gradientTransform[0] << " " << g->gradientTransform[1]
+- << " " << g->gradientTransform[2] << " " << g->gradientTransform[3]
+- << " " << g->gradientTransform[4] << " " << g->gradientTransform[5] << "] concat\n";
++ _tree->gsave();
++ *_tree << "[" << g->gradientTransform[0] << " " << g->gradientTransform[1]
++ << " " << g->gradientTransform[2] << " " << g->gradientTransform[3]
++ << " " << g->gradientTransform[4] << " " << g->gradientTransform[5] << "] concat\n";
+ }
+- os << "shfill\n";
++ *_tree << "shfill\n";
+ if (g->gradientTransform_set) {
+- os << "grestore\n";
++ _tree->grestore();
+ }
+ }
+ }
+
+- os << "grestore\n";
++ _tree->grestore();
+
+- fprintf(_stream, "%s", os.str().c_str());
+- }
++// fprintf(_stream, "%s", os.str().c_str());
++ }
+
+ return 0;
+ }
+@@ -721,15 +741,11 @@
+ if (_bitmap) return 0;
+
+ if (style->stroke.type == SP_PAINT_TYPE_COLOR) {
+- Inkscape::SVGOStringStream os;
+-
+- print_stroke_style(os, style);
+-
+- print_bpath(os, bpath->path);
++ print_stroke_style(style);
+
+- os << "stroke\n";
++ print_bpath(bpath->path);
+
+- fprintf(_stream, "%s", os.str().c_str());
++ *_tree << "stroke\n";
+ }
+
+ return 0;
+@@ -743,49 +759,25 @@
+ if (_bitmap) return 0;
+
+ return print_image(_stream, px, w, h, rs, transform);
+-#if 0
+- fprintf(_stream, "gsave\n");
+- fprintf(_stream, "/rowdata %d string def\n", 3 * w);
+- fprintf(_stream, "[%g %g %g %g %g %g] concat\n",
+- transform->c[0],
+- transform->c[1],
+- transform->c[2],
+- transform->c[3],
+- transform->c[4],
+- transform->c[5]);
+- fprintf(_stream, "%d %d 8 [%d 0 0 -%d 0 %d]\n", w, h, w, h, h);
+- fprintf(_stream, "{currentfile rowdata readhexstring pop}\n");
+- fprintf(_stream, "false 3 colorimage\n");
+-
+- for (unsigned int r = 0; r < h; r++) {
+- guchar *s;
+- unsigned int c0, c1, c;
+- s = px + r * rs;
+- for (c0 = 0; c0 < w; c0 += 24) {
+- c1 = MIN(w, c0 + 24);
+- for (c = c0; c < c1; c++) {
+- static const char xtab[] = {'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'};
+- fputc(xtab[s[0] >> 4], _stream);
+- fputc(xtab[s[0] & 0xf], _stream);
+- fputc(xtab[s[1] >> 4], _stream);
+- fputc(xtab[s[1] & 0xf], _stream);
+- fputc(xtab[s[2] >> 4], _stream);
+- fputc(xtab[s[2] & 0xf], _stream);
+- s += 4;
+- }
+- fputs("\n", _stream);
+- }
+- }
+-
+- fprintf(_stream, "grestore\n");
+-
+- return 0;
+-#endif
+ }
+
+-const char *
++const string
+ PrintPS::PSFontName(const SPStyle *style)
+ {
++
++ gchar *fname=style->text->font_family.value;
++
++ // Just pass the standard adobe font names
++ if(strcasecmp(fname, "helvetica")==0){
++ return "Helvetica";
++ } else if (strcasecmp(fname, "times")==0) {
++ return "Times";
++ } else if (strcasecmp(fname, "courier")==0) {
++ return "Courier";
++ } else if (strcasecmp(fname, "symbol")==0) {
++ return "Symbol";
++ }
++
+ font_instance *tf = (font_factory::Default())->Face(style->text->font_family.value, font_style_to_pos(*style));
+
+ char const *n;
+@@ -809,7 +801,8 @@
+ (i) ? "Italic" : ((o) ? "Oblique" : "") );
+ }
+
+- return g_strdup(n);
++ string s(n);
++ return s;
+ }
+
+
+@@ -820,45 +813,46 @@
+ if (!_stream) return 0; // XXX: fixme, returning -1 as unsigned.
+ if (_bitmap) return 0;
+
+- Inkscape::SVGOStringStream os;
+-
+ // Escape chars
+- // FlowResOut feeds us text char by char
+- if (!strcmp(text, "(")) {
+- text = "\\(";
+- } else if (!strcmp(text, ")")) {
+- text = "\\)";
+- } else if (!strcmp(text, "\\")) {
+- text = "\\\\";
++ // FlowResOut does no longer work char by char
++ string ntext;
++ const char *c=text;
++ while (*c!='\0') {
++ if (*c=='(') {
++ ntext+="\\(";
++ } else if (*c==')') {
++ ntext+="\\)";
++ } else if (*c=='\\') {
++ ntext+="\\\\";
++ } else {
++ ntext+=*c;
++ }
++ c++;
+ }
+
+ // set font
+- const char *fn = PSFontName(style);
+- os << "/" << fn << " findfont\n";
+- os << style->font_size.computed << " scalefont\n";
+- os << "setfont\n";
+- g_free((void *) fn);
++ const string fn = PSFontName(style);
++
++ _tree->setFont(fn,style->font_size.computed);
+
+ if (style->fill.type == SP_PAINT_TYPE_COLOR) {
+ // set fill style
+- print_fill_style(os, style);
++ print_fill_style(style);
+ // paint fill
+- os << "newpath\n";
+- os << p[NR::X] << " " << p[NR::Y] << " moveto\n";
+- os << "(" << text << ") show\n";
++ *_tree << "newpath\n";
++ *_tree << p[NR::X] << " " << p[NR::Y] << " moveto\n";
++ *_tree << "(" << ntext << ") show\n";
+ }
+
+ if (style->stroke.type == SP_PAINT_TYPE_COLOR) {
+ // set stroke style
+- print_stroke_style(os, style);
++ print_stroke_style(style);
+ // paint stroke
+- os << "newpath\n";
+- os << p[NR::X] << " " << p[NR::Y] << " moveto\n";
+- os << "(" << text << ") false charpath stroke\n";
++ *_tree << "newpath\n";
++ *_tree << p[NR::X] << " " << p[NR::Y] << " moveto\n";
++ *_tree << "(" << ntext << ") false charpath stroke\n";
+ }
+
+- fprintf(_stream, "%s", os.str().c_str());
+-
+ return 0;
+ }
+
+@@ -867,33 +861,33 @@
+ /* PostScript helpers */
+
+ void
+-PrintPS::print_bpath(SVGOStringStream &os, const NArtBpath *bp)
++PrintPS::print_bpath(const NArtBpath *bp)
+ {
+ unsigned int closed;
+
+- os << "newpath\n";
++ *_tree << "newpath\n";
+ closed = FALSE;
+ while (bp->code != NR_END) {
+ switch (bp->code) {
+ case NR_MOVETO:
+ if (closed) {
+- os << "closepath\n";
++ *_tree << "closepath\n";
+ }
+ closed = TRUE;
+- os << bp->x3 << " " << bp->y3 << " moveto\n";
++ *_tree << bp->x3 << " " << bp->y3 << " moveto\n";
+ break;
+ case NR_MOVETO_OPEN:
+ if (closed) {
+- os << "closepath\n";
++ *_tree << "closepath\n";
+ }
+ closed = FALSE;
+- os << bp->x3 << " " << bp->y3 << " moveto\n";
++ *_tree << bp->x3 << " " << bp->y3 << " moveto\n";
+ break;
+ case NR_LINETO:
+- os << bp->x3 << " " << bp->y3 << " lineto\n";
++ *_tree << bp->x3 << " " << bp->y3 << " lineto\n";
+ break;
+ case NR_CURVETO:
+- os << bp->x1 << " " << bp->y1 << " "
++ *_tree << bp->x1 << " " << bp->y1 << " "
+ << bp->x2 << " " << bp->y2 << " "
+ << bp->x3 << " " << bp->y3 << " curveto\n";
+ break;
+@@ -903,7 +897,7 @@
+ bp += 1;
+ }
+ if (closed) {
+- os << "closepath\n";
++ *_tree << "closepath\n";
+ }
+ }
+
+@@ -1002,8 +996,9 @@
+ }
+
+ void
+-PrintPS::ascii85_flush(SVGOStringStream &os)
++PrintPS::ascii85_flush()
+ {
++ string s;
+ char c[5];
+ int i;
+ gboolean zero_case = (ascii85_buf == 0);
+@@ -1017,31 +1012,32 @@
+ * at end of data. */
+ if (zero_case && (ascii85_len == 4)) {
+ if (ascii85_linewidth >= max_linewidth) {
+- os << '\n';
++ s += '\n';
+ ascii85_linewidth = 0;
+ }
+- os << 'z';
++ s += 'z';
+ ascii85_linewidth++;
+ } else {
+ for (i=0; i < ascii85_len+1; i++) {
+ if ((ascii85_linewidth >= max_linewidth) && (c[i] != '%')) {
+- os << '\n';
++ s += '\n';
+ ascii85_linewidth = 0;
+ }
+- os << c[i];
++ s+= c[i];
+ ascii85_linewidth++;
+ }
+ }
+
+ ascii85_len = 0;
+ ascii85_buf = 0;
++ *_tree << s;
+ }
+
+ inline void
+-PrintPS::ascii85_out(guchar byte, SVGOStringStream &os)
++PrintPS::ascii85_out(guchar byte)
+ {
+ if (ascii85_len == 4)
+- ascii85_flush(os);
++ ascii85_flush();
+
+ ascii85_buf <<= 8;
+ ascii85_buf |= byte;
+@@ -1049,24 +1045,24 @@
+ }
+
+ void
+-PrintPS::ascii85_nout(int n, guchar *uptr, SVGOStringStream &os)
++PrintPS::ascii85_nout(int n, guchar *uptr)
+ {
+ while (n-- > 0) {
+- ascii85_out(*uptr, os);
++ ascii85_out(*uptr);
+ uptr++;
+ }
+ }
+
+ void
+-PrintPS::ascii85_done(SVGOStringStream &os)
++PrintPS::ascii85_done()
+ {
+ if (ascii85_len) {
+ /* zero any unfilled buffer portion, then flush */
+ ascii85_buf <<= (8 * (4-ascii85_len));
+- ascii85_flush(os);
++ ascii85_flush();
+ }
+
+- os << "~>\n";
++ *_tree << "~>\n";
+ }
+
+ unsigned int
+@@ -1076,35 +1072,34 @@
+ unsigned int i, j;
+ /* gchar *data, *src; */
+ guchar *packb = NULL, *plane = NULL;
+- Inkscape::SVGOStringStream os;
+
+- os << "gsave\n";
+- os << "[" << transform->c[0] << " "
++ _tree->gsave();
++ *_tree << "[" << transform->c[0] << " "
+ << transform->c[1] << " "
+ << transform->c[2] << " "
+ << transform->c[3] << " "
+ << transform->c[4] << " "
+ << transform->c[5] << "] concat\n";
+- os << width << " " << height << " 8 ["
++ *_tree << width << " " << height << " 8 ["
+ << width << " 0 0 -" << height << " 0 " << height << "]\n";
+
+
+ /* Write read image procedure */
+- os << "% Strings to hold RGB-samples per scanline\n";
+- os << "/rstr " << width << " string def\n";
+- os << "/gstr " << width << " string def\n";
+- os << "/bstr " << width << " string def\n";
+- os << "{currentfile /ASCII85Decode filter /RunLengthDecode filter rstr readstring pop}\n";
+- os << "{currentfile /ASCII85Decode filter /RunLengthDecode filter gstr readstring pop}\n";
+- os << "{currentfile /ASCII85Decode filter /RunLengthDecode filter bstr readstring pop}\n";
+- os << "true 3\n";
++ *_tree << "% Strings to hold RGB-samples per scanline\n";
++ *_tree << "/rstr " << width << " string def\n";
++ *_tree << "/gstr " << width << " string def\n";
++ *_tree << "/bstr " << width << " string def\n";
++ *_tree << "{currentfile /ASCII85Decode filter /RunLengthDecode filter rstr readstring pop}\n";
++ *_tree << "{currentfile /ASCII85Decode filter /RunLengthDecode filter gstr readstring pop}\n";
++ *_tree << "{currentfile /ASCII85Decode filter /RunLengthDecode filter bstr readstring pop}\n";
++ *_tree << "true 3\n";
+
+ /* Allocate buffer for packbits data. Worst case: Less than 1% increase */
+ packb = (guchar *)g_malloc((width * 105)/100+2);
+ plane = (guchar *)g_malloc(width);
+
+ /* ps_begin_data(ofp); */
+- os << "colorimage\n";
++ *_tree << "colorimage\n";
+
+ #define GET_RGB_TILE(begin) \
+ {int scan_lines; \
+@@ -1131,31 +1126,17 @@
+ compress_packbits(width, plane, &nout, packb);
+
+ ascii85_init();
+- ascii85_nout(nout, packb, os);
+- ascii85_out(128, os); /* Write EOD of RunLengthDecode filter */
+- ascii85_done(os);
++ ascii85_nout(nout, packb);
++ ascii85_out(128); /* Write EOD of RunLengthDecode filter */
++ ascii85_done();
+ }
+ }
+ /* ps_end_data(ofp); */
+
+-#if 0
+- fprintf(ofp, "showpage\n");
+- g_free(data);
+-#endif
+-
+ g_free(packb);
+ g_free(plane);
+
+-#if 0
+- if (ferror(ofp)) {
+- g_message(_("write error occurred"));
+- return (FALSE);
+- }
+-#endif
+-
+- os << "grestore\n";
+-
+- fprintf(ofp, "%s", os.str().c_str());
++ _tree->grestore();
+
+ return 0;
+ #undef GET_RGB_TILE
+diff -urN inkscape-20050326-2100.orig/src/extension/internal/ps.h inkscape-20050326-2100/src/extension/internal/ps.h
+--- inkscape-20050326-2100.orig/src/extension/internal/ps.h 2005-03-27 07:01:06.000000000 +0200
++++ inkscape-20050326-2100/src/extension/internal/ps.h 2005-03-29 13:59:42.000000000 +0200
+@@ -5,8 +5,8 @@
+ * This is the internal module used to do Postscript Printing
+ *
+ * Author:
+- * Lauris Kaplinski <lauris@kaplinski.com>
+- * Ted Gould <ted@gould.cx>
++ * Lauris Kaplinski <lauris@kaplinski.com>
++ * Ted Gould <ted@gould.cx>
+ *
+ * Lauris: This code is in the public domain
+ * Ted: This code is under the GNU GPL
+@@ -19,6 +19,9 @@
+ #include <libnr/nr-path.h>
+
+ #include "svg/stringstream.h"
++#include <string>
++#include <memory>
++#include "pstree.h"
+
+ namespace Inkscape {
+ namespace Extension {
+@@ -30,58 +33,58 @@
+ FILE * _stream;
+ unsigned short _dpi;
+ bool _bitmap;
++ std::auto_ptr<Inkscape::Extension::Internal::PS::PSTree> _tree;
+
+- void print_bpath (SVGOStringStream &os, const NArtBpath *bp);
++ void print_bpath (const NArtBpath *bp);
+
+- void PrintPS::print_fill_style (SVGOStringStream &os, const SPStyle *style);
+- void PrintPS::print_stroke_style (SVGOStringStream &os, const SPStyle *style);
++ void PrintPS::print_fill_style (const SPStyle *style);
++ void PrintPS::print_stroke_style (const SPStyle *style);
+
+- const char* PrintPS::PSFontName (const SPStyle *style);
+-
+- unsigned int print_image (FILE *ofp, guchar *px, unsigned int width, unsigned int height, unsigned int rs,
+- const NRMatrix *transform);
+- void compress_packbits (int nin, guchar *src, int *nout, guchar *dst);
+-
+- /* ASCII 85 variables */
+- guint32 ascii85_buf;
+- int ascii85_len;
+- int ascii85_linewidth;
+- /* ASCII 85 Functions */
+- void ascii85_init (void);
+- void ascii85_flush (SVGOStringStream &os);
+- inline void ascii85_out (guchar byte, SVGOStringStream &os);
+- void ascii85_nout (int n, guchar *uptr, SVGOStringStream &os);
+- void ascii85_done (SVGOStringStream &os);
++ const std::string PrintPS::PSFontName (const SPStyle *style);
+
++ unsigned int print_image (FILE *ofp, guchar *px, unsigned int width, unsigned int height, unsigned int rs,
++ const NRMatrix *transform);
++ void compress_packbits (int nin, guchar *src, int *nout, guchar *dst);
++
++ /* ASCII 85 variables */
++ guint32 ascii85_buf;
++ int ascii85_len;
++ int ascii85_linewidth;
++ /* ASCII 85 Functions */
++ void ascii85_init (void);
++ void ascii85_flush ();
++ inline void ascii85_out (guchar byte);
++ void ascii85_nout (int n, guchar *uptr);
++ void ascii85_done ();
+
+ public:
+- PrintPS (void);
+- virtual ~PrintPS (void);
++ PrintPS (void);
++ virtual ~PrintPS (void);
+
+- /* Print functions */
+- virtual unsigned int setup (Inkscape::Extension::Print * module);
+- /*
+- virtual unsigned int set_preview (Inkscape::Extension::Print * module);
+- */
+-
+- virtual unsigned int begin (Inkscape::Extension::Print * module, SPDocument *doc);
+- virtual unsigned int finish (Inkscape::Extension::Print * module);
+-
+- /* Rendering methods */
+- virtual unsigned int bind (Inkscape::Extension::Print * module, const NRMatrix *transform, float opacity);
+- virtual unsigned int release (Inkscape::Extension::Print * module);
+- virtual unsigned int comment (Inkscape::Extension::Print * module, const char * comment);
+- virtual unsigned int fill (Inkscape::Extension::Print * module, const NRBPath *bpath, const NRMatrix *ctm, const SPStyle *style,
+- const NRRect *pbox, const NRRect *dbox, const NRRect *bbox);
+- virtual unsigned int stroke (Inkscape::Extension::Print * module, const NRBPath *bpath, const NRMatrix *transform, const SPStyle *style,
+- const NRRect *pbox, const NRRect *dbox, const NRRect *bbox);
+- virtual unsigned int image (Inkscape::Extension::Print * module, unsigned char *px, unsigned int w, unsigned int h, unsigned int rs,
+- const NRMatrix *transform, const SPStyle *style);
++ /* Print functions */
++ virtual unsigned int setup (Inkscape::Extension::Print * module);
++ /*
++ virtual unsigned int set_preview (Inkscape::Extension::Print * module);
++ */
++
++ virtual unsigned int begin (Inkscape::Extension::Print * module, SPDocument *doc);
++ virtual unsigned int finish (Inkscape::Extension::Print * module);
++
++ /* Rendering methods */
++ virtual unsigned int bind (Inkscape::Extension::Print * module, const NRMatrix *transform, float opacity);
++ virtual unsigned int release (Inkscape::Extension::Print * module);
++ virtual unsigned int comment (Inkscape::Extension::Print * module, const char * comment);
++ virtual unsigned int fill (Inkscape::Extension::Print * module, const NRBPath *bpath, const NRMatrix *ctm, const SPStyle *style,
++ const NRRect *pbox, const NRRect *dbox, const NRRect *bbox);
++ virtual unsigned int stroke (Inkscape::Extension::Print * module, const NRBPath *bpath, const NRMatrix *transform, const SPStyle *style,
++ const NRRect *pbox, const NRRect *dbox, const NRRect *bbox);
++ virtual unsigned int image (Inkscape::Extension::Print * module, unsigned char *px, unsigned int w, unsigned int h, unsigned int rs,
++ const NRMatrix *transform, const SPStyle *style);
+ virtual unsigned int text (Inkscape::Extension::Print *module, const char *text,
+- NR::Point p, const SPStyle *style);
++ NR::Point p, const SPStyle *style);
+
+- bool textToPath (Inkscape::Extension::Print * ext);
+- static void init (void);
++ bool textToPath (Inkscape::Extension::Print * ext);
++ static void init (void);
+ };
+
+ } /* namespace Internal */
+diff -urN inkscape-20050326-2100.orig/src/extension/internal/pstree.cpp inkscape-20050326-2100/src/extension/internal/pstree.cpp
+--- inkscape-20050326-2100.orig/src/extension/internal/pstree.cpp 1970-01-01 01:00:00.000000000 +0100
++++ inkscape-20050326-2100/src/extension/internal/pstree.cpp 2005-03-29 13:59:42.000000000 +0200
+@@ -0,0 +1,137 @@
++//
++// C++ Implementation: pstree
++//
++// Description:
++//
++//
++// Author: Paul de Vrieze <pauldv@cs.ru.nl>, (C) 2005
++//
++// Copyright: See COPYING file that comes with this distribution
++//
++//
++#include "pstree.h"
++#include <sstream>
++
++namespace Inkscape {
++
++namespace Extension {
++
++namespace Internal {
++
++namespace PS {
++
++using namespace std;
++
++PSTree::PSTree() : PSBlock(0)
++{
++ _current = this;
++}
++
++PSTree& PSTree::put (const string &s) {
++ _current->addElem(new MiscPSElem(s));
++ return *this;
++}
++
++PSTree& PSTree::operator<<(const std::string &s){
++ return put(s);
++}
++
++PSTree& PSTree::operator<<(int i){
++ std::ostringstream s;
++ s<< i;
++ return put(s.str());
++}
++
++PSTree& PSTree::operator<<(unsigned int i){
++ std::ostringstream s;
++ s<< i;
++ return put(s.str());
++}
++
++PSTree& PSTree::operator<<(float f){
++ ostringstream s;
++ s.imbue(std::locale::classic());
++ s.setf(std::ios::showpoint);
++ s.precision(8);
++ s<< f;
++ return put(s.str());
++}
++
++PSTree& PSTree::operator<<(double d){
++ ostringstream s;
++ s.imbue(std::locale::classic());
++ s.setf(std::ios::showpoint);
++ s.precision(8);
++ s<< d;
++ return put(s.str());
++}
++
++PSTree& PSTree::grestore() {
++ _current=_current->parent();
++ put("grestore\n");
++ return *this;
++}
++
++PSTree& PSTree::gsave() {
++ PSBlock *nb = new PSBlock(_current);
++ _current->addElem(nb);
++ _current=nb;
++ put("gsave\n");
++ return *this;
++}
++
++bool hasFont(const PSBlock *obj, const PSFontMetric &metr) {
++ if (obj==0) { return false; }
++ if (obj->font().size() >=0) {
++ return (obj->font()==metr);
++ }
++ return hasFont(obj->parent(),metr);
++}
++
++PSTree &PSTree::setFont(const string &name, const float &size) {
++ PSFontMetric metr(name,size);
++ if (! hasFont(_current, metr)) {
++ *this << "/" <<name << " findfont\n";
++ *this << size << " scalefont\n";
++ *this << "setfont\n";
++ _current->setFont(metr);
++ }
++ return *this;
++}
++
++string PSBlock::str() {
++ string s;
++ for(vector<PSElem*>::iterator it=_elems.begin(); it !=_elems.end(); it++){
++ s += (*it)->str();
++ }
++ return s;
++}
++
++void PSBlock::addElem(PSElem *elem){
++ _elems.push_back(elem);
++}
++
++PSBlock::~PSBlock(){
++ while (! _elems.empty()) {
++ delete _elems[0];
++ }
++}
++
++PSFontMetric::PSFontMetric(const std::string s, const float f)
++ : _fontname(s), _computedsize(f) { }
++
++bool PSFontMetric::operator==(const PSFontMetric &m) const {
++ return (_computedsize==m._computedsize) && (_fontname==m._fontname);
++}
++
++bool PSFontMetric::operator!=(const PSFontMetric &m) const {
++ return (_fontname!=m._fontname) || (_computedsize!=m._computedsize);
++}
++
++} // Namespace PS
++
++}
++
++}
++
++}
+diff -urN inkscape-20050326-2100.orig/src/extension/internal/pstree.h inkscape-20050326-2100/src/extension/internal/pstree.h
+--- inkscape-20050326-2100.orig/src/extension/internal/pstree.h 1970-01-01 01:00:00.000000000 +0100
++++ inkscape-20050326-2100/src/extension/internal/pstree.h 2005-03-29 13:59:42.000000000 +0200
+@@ -0,0 +1,103 @@
++//
++// C++ Interface: pstree
++//
++// Description:
++//
++//
++// Author: Paul de Vrieze <pauldv@cs.ru.nl>, (C) 2005
++//
++// Copyright: See COPYING file that comes with this distribution
++//
++//
++#ifndef INKSCAPE_EXTENSION_INTERNAL_PSPSTREE_H
++#define INKSCAPE_EXTENSION_INTERNAL_PSPSTREE_H
++
++#include <vector>
++#include <string>
++
++namespace Inkscape {
++
++namespace Extension {
++
++namespace Internal {
++
++namespace PS {
++
++/**
++ * An utterance of postscript
++ */
++class PSElem{
++public:
++ virtual std::string str() = 0;
++};
++
++class MiscPSElem : public PSElem {
++ std::string _value;
++public:
++ MiscPSElem(const std::string value) : _value(value) {};
++ virtual std::string str() { return _value; };
++ virtual ~MiscPSElem() {};
++};
++
++
++class PSFontMetric {
++ private:
++ std::string _fontname;
++ float _computedsize;
++
++ public:
++ PSFontMetric(const std::string s="", const float f=-1);
++ bool operator==(const PSFontMetric&) const;
++ bool operator!=(const PSFontMetric&) const;
++ std::string fontname() const { return _fontname; };
++ float size() const { return _computedsize; };
++};
++
++
++class PSBlock : public PSElem{
++private:
++ std::vector<PSElem *> _elems;
++ PSBlock *_parent;
++ PSFontMetric _font;
++public:
++ PSBlock(PSBlock *parent) : _parent(parent) {};
++ void addElem(PSElem *elem);
++ virtual std::string str();
++ virtual ~PSBlock();
++ PSBlock *parent() const { return _parent; };
++ void setFont(const PSFontMetric &font){ _font=font; };
++ const PSFontMetric &font() const { return _font; }
++};
++
++/**
++ * @author Paul de Vrieze
++ */
++class PSTree : public PSBlock{
++private:
++ PSBlock *_current;
++public:
++ PSTree();
++// virtual ~PSTree();
++ PSTree& put (const std::string &s);
++ PSTree &operator<<(const std::string &s);
++ PSTree &operator<<(int i);
++ PSTree &operator<<(unsigned int i);
++ PSTree &operator<<(float f);
++ PSTree &operator<<(double d);
++ PSTree &grestore();
++ PSTree &gsave();
++ PSTree &setFont(const std::string &name, const float &size);
++// PSTree &operator<<(const char * s);
++};
++
++//PSTree &operator<< (PSTree &tree, const std::string &s);
++
++}
++
++}
++
++}
++
++}
++
++#endif