Export As SVG with 0 decimals fails in handling closed bezier curves
When using “Export for Screens…” or “Export As…” for exporting an SVG and setting the number of decimals to 0, the exporter succeeds in encoding primitives like rects, ellipses, circles and polygons, using only integers for their coordinates – but when your artwork contains any closed bezier curves (e.g. drawn with the pen tool or derived from a font) the resulting path elements will look something like <path d="M0,0Z"/> or <path d="M0,0H0M0,0H0M0,0H0M0,0H0M0,0H0M0,0H0M0,0Z"/>
What’s surprising about the bug is that the export of non-closed bezier curves works just fine.
Steps to reproduce:
- Create a new Illustrator file
- Draw a custom path with the pen tool, click on the first point to close it
- Choose File > Export for Screens…
- In the ‘Formats’ section choose SVG
- Click the tiny gear icon to open the “Advanced settings for exported file types” dialog
- In the left-hand column select ‘SVG’
- In the ‘Decimal’ input field type ‘0’
- Hit “Save Settings”
- Hit “Export Artboard”
As a result you will end up with an SVG file that’s encoded as expected, except for the value of the path elemnt’s d-attribute, so in turn your SVG file will render as if it were empty.
Now why in heavens would I even need an SVG with so little precision? Well, when preparing assets for web content like animated advertising creatives, the pressure for ever-smaller assets is so high, that I would like to reduce my SVG’s file size by scaling it up 10-fold then outputting the coordinates as integers, and then scaling down again when displaying, thus ending up with an effective precision of one decimal, but saving the extra storage for the decimal point itself. I’ve tried it and it can save me around 20-30% storage without any loss in quality.
So not having to resort to third party tools like SVGO for making this work would obviously speed up my workflow a lot.
Thanks for fixing.
Clay Ravin commented
I totally agree. I have an Illustrator file that I'd like to turn into an SVG background pattern. Unfortunately Safari (and some versions of Firefox) will display gaps in the background if there are any values with decimal points along the edge, so it's vital to be able to export successfully with 0 decimals.