From 93668cdafd65d6c4f6197c4fb3a47b4aefc42584 Mon Sep 17 00:00:00 2001 From: scislac Date: Sat, 3 Oct 2009 21:05:18 +0000 Subject: [PATCH] Patch by Johan to fix reading of rare svg strings. --- src/2geom/svg-path.h | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/src/2geom/svg-path.h b/src/2geom/svg-path.h index f2902750c..f1fd67867 100644 --- a/src/2geom/svg-path.h +++ b/src/2geom/svg-path.h @@ -64,33 +64,58 @@ public: void moveTo(Point p) { finish(); _path.start(p); + _start_p = p; _in_path = true; } //TODO: what if _in_path = false? void hlineTo(Coord v) { - _path.template appendNew(Point(v, _path.finalPoint()[Y])); + // check for implicit moveto, like in: "M 1,1 L 2,2 z l 2,2 z" + if (!_in_path) { + moveTo(_start_p); + } + _path.template appendNew(Point(v, _path.finalPoint()[Y])); } void vlineTo(Coord v) { - _path.template appendNew(Point(_path.finalPoint()[X], v)); + // check for implicit moveto, like in: "M 1,1 L 2,2 z l 2,2 z" + if (!_in_path) { + moveTo(_start_p); + } + _path.template appendNew(Point(_path.finalPoint()[X], v)); } void lineTo(Point p) { + // check for implicit moveto, like in: "M 1,1 L 2,2 z l 2,2 z" + if (!_in_path) { + moveTo(_start_p); + } _path.template appendNew(p); } void quadTo(Point c, Point p) { + // check for implicit moveto, like in: "M 1,1 L 2,2 z l 2,2 z" + if (!_in_path) { + moveTo(_start_p); + } _path.template appendNew(c, p); } void curveTo(Point c0, Point c1, Point p) { + // check for implicit moveto, like in: "M 1,1 L 2,2 z l 2,2 z" + if (!_in_path) { + moveTo(_start_p); + } _path.template appendNew(c0, c1, p); } void arcTo(double rx, double ry, double angle, bool large_arc, bool sweep, Point p) { + // check for implicit moveto, like in: "M 1,1 L 2,2 z l 2,2 z" + if (!_in_path) { + moveTo(_start_p); + } _path.template appendNew(rx, ry, angle, large_arc, sweep, p); } @@ -113,6 +138,7 @@ protected: bool _in_path; OutputIterator _out; Path _path; + Point _start_p; }; typedef std::back_insert_iterator > iter; -- 2.30.2