SlugFiller / godot-vector2d

2D vector graphics plugin for Godot
The Unlicense
2 stars 1 forks source link

Simple path with hole not rendering at all #2

Closed Giwayume closed 1 year ago

Giwayume commented 1 year ago

Try this svg. If I remove the commands that generate the hole, the shape renders.

painting_hole

SlugFiller commented 1 year ago

Fixed in 378ee47f219920f3c06efbb951d71d56299c7208

The issue had nothing to do with the hole itself, but rather, the way Adobe Illustrator minifies the path. It uses strings like c-53.758,24.277-76.878,17.919-117.919-32.948 to represent c -53.758,24.277 -76.878,17.919 -117.919,-32.948. The SVG specs allows both comma and whitespace to be used between any two numbers, but the use of just a "-" sign as a separator was unexpected. The spec simply says "Superfluous white space and separators such as commas can be eliminated", but doesn't detail what counts as "superfluous", so this is theoretically legal.

I modified the parser to accept a sign (+/-) as a 0-length separator. Simultaneously,I changed it to no longer accept more than a single comma between two numbers (e.g. 100,,200), nor accept a comma between the command and the first number (e.g. M,100,100). The standard doesn't necessarily imply these cases are invalid, but they don't make much sense, and it's unlikely any generator or author would put these in an SVG.

Giwayume commented 1 year ago

Yeah, I had the exact same issue in my project.

Giwayume commented 1 year ago

Looks good on my side image