diff --git a/Source/Paths/SvgClosePathSegment.cs b/Source/Paths/SvgClosePathSegment.cs index d0c7ffbf94cf12919d47d2c26342a2c8b0e56afc..8ad928ae7b23af791602c22356b4bdd97f1279bc 100644 --- a/Source/Paths/SvgClosePathSegment.cs +++ b/Source/Paths/SvgClosePathSegment.cs @@ -8,10 +8,15 @@ namespace Svg.Pathing { public override void AddToPath(System.Drawing.Drawing2D.GraphicsPath graphicsPath) { + if (graphicsPath.PointCount == 0) + { + return; + } + // Important for custom line caps. Force the path the close with an explicit line, not just an implicit close of the figure. var pathPoints = graphicsPath.PathPoints; - if (pathPoints.Length > 0 && !pathPoints[0].Equals(pathPoints[pathPoints.Length - 1])) + if (!pathPoints[0].Equals(pathPoints[pathPoints.Length - 1])) { var pathTypes = graphicsPath.PathTypes; int i = pathPoints.Length - 1; diff --git a/Source/Paths/SvgLineSegment.cs b/Source/Paths/SvgLineSegment.cs index 61ed7083cb96b194feb5466a098bcb915f9d1937..1492dd313947eabecdb1fe3d979de23f60bd0722 100644 --- a/Source/Paths/SvgLineSegment.cs +++ b/Source/Paths/SvgLineSegment.cs @@ -15,7 +15,10 @@ namespace Svg.Pathing public override void AddToPath(System.Drawing.Drawing2D.GraphicsPath graphicsPath) { - graphicsPath.AddLine(this.Start, this.End); + if (this.Start != this.End) + { + graphicsPath.AddLine(this.Start, this.End); + } } public override string ToString() diff --git a/Source/Paths/SvgMoveToSegment.cs b/Source/Paths/SvgMoveToSegment.cs index e9e1e3ceca528ec9ce70d7ebd29186323f9b30c0..1b493159c62361d7af14fc0e9517737a6a2375bd 100644 --- a/Source/Paths/SvgMoveToSegment.cs +++ b/Source/Paths/SvgMoveToSegment.cs @@ -15,7 +15,10 @@ namespace Svg.Pathing public override void AddToPath(System.Drawing.Drawing2D.GraphicsPath graphicsPath) { - graphicsPath.StartFigure(); + if (this.Start != this.End) + { + graphicsPath.StartFigure(); + } } public override string ToString()