CairoSVG icon indicating copy to clipboard operation
CairoSVG copied to clipboard

SVG path parse error

Open dfung opened this issue 1 year ago • 0 comments

CairoSVG generates an error when calling svg2png for this simple svg example:

<svg xmlns="http://www.w3.org/2000/svg" width="556.76" height="1080" viewBox="0 0 556.76 1080">
<path d="M364.75 477.76c-4.36.0-6.89 3.37-7.35 7.35a2e2 2e2.0 0 0-.92 23c0 9.48 14.7 9.48 14.7.0a2e2 2e2.0 0 1 .92-23C372.56 481.12 368.41 477.76 364.75 477.76z" />
</svg>

I think the issue is with the point() helper function which does not fully match up with the number definition in the SVG specification.

  • https://github.com/Kozea/CairoSVG/blob/9a1bf51b2eea5b4ea82114af436f5ff64f53ab27/cairosvg/helpers.py#L86
  • https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#number

The point() function fails to decode this string "2e2 2e2.0 0 0-.92 23" as (2e2, 2e2, '.0 0 0-.92 23') but instead returns (2e2, 2e2.0, '0 0-.92 23'). The SVG spec does not appear to allow decimals in the exponent value.

dfung avatar Apr 22 '24 20:04 dfung