Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Paths should be rendered up to the location of error #68

Closed
jinsihou19 opened this issue Mar 6, 2024 · 2 comments
Closed

Paths should be rendered up to the location of error #68

jinsihou19 opened this issue Mar 6, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@jinsihou19
Copy link

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)
@weisJ weisJ changed the title Svg parse error Paths should be rendered up to the loction of error Mar 6, 2024
@weisJ weisJ added the enhancement New feature or request label Mar 6, 2024
@weisJ
Copy link
Owner

weisJ commented Mar 6, 2024

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).

@weisJ weisJ changed the title Paths should be rendered up to the loction of error Paths should be rendered up to the location of error Mar 6, 2024
weisJ added a commit that referenced this issue Mar 8, 2024
@weisJ
Copy link
Owner

weisJ commented Mar 11, 2024

The new snapshot version should render the file as expected.

@weisJ weisJ closed this as completed Mar 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants