linebender / resvg

An SVG rendering library.
Apache License 2.0
2.85k stars 228 forks source link

Incorrect s command simplification #807

Closed woodroof closed 3 months ago

woodroof commented 3 months ago

Specifications says "If there is no previous command or if the previous command was not an C, c, S or s, assume the first control point is coincident with the current point." Example: <path d="M 1 5 A 5.389 5.389 0 0 1 3 1 s 2.5 2 8 2 Z"> usvg first changes A command to C and then uses this C command to calculate s first control point, but that is incorrect. Current result: M 1 5 C 1.0558429 3.4399235 1.7854446 1.9807202 3 1 C 4.2145553 0.01927989 5.5 3 11 3 Z Correct result: M 1 5 C 1.0558429 3.4399235 1.7854446 1.9807202 3 1 C 3 1 5.5 3 11 3.

Test svg: test Actual result: actual Expected result: expected

RazrFalcon commented 3 months ago

Yep. Broke it a year ago trying to simplify path parsing. Lack of testing... SVG paths are truly insane.