tl;dr: Given arbitrary SVG <path>
how can I adjust the path commands to set a new origin for the file?
Details
I'm using Adobe Illustrator to create vector graphics for use in Android. Illustrator has a bug where under (unknown) circumstances the viewBox
and all coordinates created for your graphics do not match the coordinates you set for the canvas and objects in Illustrator. Instead of (for example) viewBox="-7 0 14 20"
you might get viewBox="-53 75 14 20"
. Usually the the path commands will be translated to fit inside that viewBox. Sometimes even that fails.
In a normal SVG file (a) this would rarely even be noticeable, and (b) it would be easy to fix by wrapping everything in a root-level <g transform="translate(46,-75)">
. In an Android VectorDrawable
this requires an extra <group>
that I don't want to add, and (unlike SVG) I can't add a translate to the <path>
itself. And in my code, the origin matters.
How can I adjust the path commands for all the paths in an SVG file to offset them by a fixed amount, allowing me to place the origin where I'd like?