weisJ/jsvg

Paths should be rendered up to the location of error

jinsihou19 opened this issue · 2 comments

The svg file in the attachment can be rendered in idea.
Expect it can be rendered without error.

bbs

java.lang.IllegalStateException: Unexpected token '-' rest=-nan -nanL(index=580 in input=M23.9999 16H25.3429H25.9999H27.9999H28.1714L26.1714 14L17.414 5.24264L15.9998 3.82843L14.5856 5.24264L5.82823 14L3.82823 16H3.99987H5.99987H6.65666H7.99987V18V20V25V27H9.99987H12V25V23.0001C12 21.8955 12.8954 21.0001 14 21.0001H18C19.1046 21.0001 20 21.8955 20 23.0001V25V27H21.9999H23.9999V25V20V18V16ZM29.5856 14.5858L18.8282 3.82843L17.414 2.41422L17.4128 2.41304C16.7644 1.76564 15.7822 1.65594 15.0206 2.08394C14.8648 2.17152 14.7182 2.28161 14.5856 2.41422L2.41401 14.5858C1.15409 15.8457 2.04642 18 3.82823 18H3.99987H5.99987V20V27C5.99987 28.1046 6.8953 29 7.99987 29H12L-nan -nanL12 29C13.0997 29 13.9912 28.0997 13.9912 27.0001L-nan -nanL13.9912 27.0001H17.9999L-nan -nanL17.9999 27.0001C18.0048 28.1011 18.8989 29 20 29L-nan -nanL20 29H23.9999C25.1044 29 25.9999 28.1046 25.9999 27V20V18H27.9999H28.1714C29.9526 18 30.8449 15.8471 29.5868 14.587L29.5856 14.5858ZM17.9999 27.0001L18 23.0001H14V24L13.9912 27.0001H17.9999Z)
	at com.github.weisj.jsvg.util.ParserBase.nextFloat(ParserBase.java:85)
	at com.github.weisj.jsvg.geometry.path.PathParser.nextFloat(PathParser.java:49)
	at com.github.weisj.jsvg.geometry.path.PathParser.parsePathCommand(PathParser.java:115)
	at com.github.weisj.jsvg.util.PathUtil.parseFromPathData(PathUtil.java:56)
	at com.github.weisj.jsvg.nodes.Path.buildShape(Path.java:60)
	at com.github.weisj.jsvg.nodes.ShapeNode.build(ShapeNode.java:91)
	at com.github.weisj.jsvg.parser.ParsedElement.build(ParsedElement.java:116)
	at com.github.weisj.jsvg.parser.ParsedElement.build(ParsedElement.java:114)

The svg path is invalid as it contains L-nan -nan.
Your svg file is equivalent to:

<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">
  <path fill-rule="evenodd" clip-rule="evenodd"  fill="#0A1C38" fill-opacity="0.9"
        d="M23.9999 16H25.3429H25.9999H27.9999H28.1714L26.1714 14L17.414 5.24264L15.9998 3.82843L14.5856 5.24264L5.82823 14L3.82823 16H3.99987H5.99987H6.65666H7.99987V18V20V25V27H9.99987H12V25V23.0001C12 21.8955 12.8954 21.0001 14 21.0001H18C19.1046 21.0001 20 21.8955 20 23.0001V25V27H21.9999H23.9999V25V20V18V16ZM29.5856 14.5858L18.8282 3.82843L17.414 2.41422L17.4128 2.41304C16.7644 1.76564 15.7822 1.65594 15.0206 2.08394C14.8648 2.17152 14.7182 2.28161 14.5856 2.41422L2.41401 14.5858C1.15409 15.8457 2.04642 18 3.82823 18H3.99987H5.99987V20V27C5.99987 28.1046 6.8953 29 7.99987 29H12"/>
        <!-- L-nan -nanL12 29C13.0997 29 13.9912 28.0997 13.9912 27.0001
        L-nan -nanL13.9912 27.0001H17.9999
        L-nan -nanL17.9999 27.0001C18.0048 28.1011 18.8989 29 20 29
        L-nan -nanL20 29H23.9999C25.1044 29 25.9999 28.1046 25.9999 27V20V18H27.9999H28.1714C29.9526 18 30.8449 15.8471 29.5868 14.587L29.5856 14.5858ZM17.9999 27.0001L18 23.0001H14V24L13.9912 27.0001H17.9999Z"/> -->
</svg>

The spec says to render paths up to the first point of error. This isn't currently supported (but is an easy fix).

The new snapshot version should render the file as expected.