Commit 9b224b2b authored by Ritch Melton's avatar Ritch Melton
Browse files

Fixed up empty string fix

parent 1585c700
...@@ -293,23 +293,16 @@ namespace Svg ...@@ -293,23 +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; .Select(n => string.IsNullOrEmpty(n.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;
//When an empty string is passed to GraphicsPath, it raises an InvalidArgumentException. if (_path == null || IsPathDirty || nodes.Any())
//if there is a TSpan inside of this text element then path should not be null (even if this text is empty!)
var isInvalidText = string.IsNullOrEmpty(Text) && !Children.Any(x => x is SvgContentNode);
if (_path == null || IsPathDirty || isInvalidText)
{ {
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