diff --git a/src/tools/svg2tvgt/svg2tvgt.cs b/src/tools/svg2tvgt/svg2tvgt.cs index 0228c81..fc55c40 100644 --- a/src/tools/svg2tvgt/svg2tvgt.cs +++ b/src/tools/svg2tvgt/svg2tvgt.cs @@ -1633,6 +1633,7 @@ public static void Parse(string str, IPathRenderer renderer) int char_offset = 0; PointF current_position = new PointF(0, 0); + PointF? path_start = null; PointF? stored_control_point = null; private SvgPathParser(string str, IPathRenderer renderer) @@ -1836,6 +1837,9 @@ void ParseDrawToCommand() void ParseClosePath() { AcceptChar('Z', 'z'); + if (path_start == null) throw new InvalidOperationException("ClosePath detected without MoveTo"); + current_position = (PointF)path_start; + path_start = null; renderer.ClosePath(); SkipWhitespace(); } @@ -1852,6 +1856,8 @@ void ParseMoveTo() var p = MoveCursor(pair, relative); if (first) { + if (path_start != null) throw new InvalidOperationException("New MoveTo detected without ClosePath"); + path_start = current_position; renderer.MoveTo(p); } else