Commit a653b4a4 authored by Tebjan Halm's avatar Tebjan Halm
Browse files

Merge pull request #99 from skyguy94/FixForNullPath

Fix for null path
parents 1818255b 909fc1f8
...@@ -293,19 +293,16 @@ namespace Svg ...@@ -293,19 +293,16 @@ namespace Svg
/// Gets the <see cref="GraphicsPath"/> for this element. /// Gets the <see cref="GraphicsPath"/> for this element.
/// </summary> /// </summary>
/// <value></value> /// <value></value>
public override System.Drawing.Drawing2D.GraphicsPath Path(ISvgRenderer renderer) public override GraphicsPath Path(ISvgRenderer renderer)
{ {
// Make sure the path is always null if there is no text
//if there is a TSpan inside of this text element then path should not be null (even if this text is empty!) //if there is a TSpan inside of this text element then path should not be null (even if this text is empty!)
var nodes = this.GetContentNodes().ToList(); var nodes = GetContentNodes().Where(x => x is SvgContentNode &&
if (nodes.Count < 1) return _path = null; string.IsNullOrEmpty(x.Content.Trim(new[] {'\r', '\n', '\t'})));
if (nodes.Count == 1 && nodes[0] is SvgContentNode &&
(string.IsNullOrEmpty(nodes[0].Content) || nodes[0].Content.Trim().Length < 1)) return _path = null;
if (_path == null || this.IsPathDirty) if (_path == null || IsPathDirty || nodes.Count() == 1)
{ {
renderer = (renderer ?? SvgRenderer.FromNull()); renderer = (renderer ?? SvgRenderer.FromNull());
this.SetPath(new TextDrawingState(renderer, this)); SetPath(new TextDrawingState(renderer, this));
} }
return _path; return _path;
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment