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
/// Gets the <see cref="GraphicsPath"/> for this element.
/// </summary>
/// <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!)
var nodes = this.GetContentNodes().ToList();
if (nodes.Count < 1) return _path = null;
if (nodes.Count == 1 && nodes[0] is SvgContentNode &&
(string.IsNullOrEmpty(nodes[0].Content) || nodes[0].Content.Trim().Length < 1)) return _path = null;
var nodes = GetContentNodes().Where(x => x is SvgContentNode)
.Select(n => string.IsNullOrEmpty(n.Content.Trim(new[] {'\r', '\n', '\t'})));
//When an empty string is passed to GraphicsPath, it raises an InvalidArgumentException.
//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)
if (_path == null || IsPathDirty || nodes.Any())
{
renderer = (renderer ?? SvgRenderer.FromNull());
this.SetPath(new TextDrawingState(renderer, this));
SetPath(new TextDrawingState(renderer, this));
}
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