swhitty / SwiftDraw

Swift library and command line tool to convert SVGs into SFSymbol, PNG, PDF and Swift source code.
zlib License
389 stars 49 forks source link

How to maintain inserts from svg file #22

Closed vladzz closed 1 year ago

vladzz commented 1 year ago

We need to maintain inserts from Figma designs like so: image

However when we use swiftdraw to convert all the svg's assets given to us it seems to remove those inserts and put in autogenerated ones. Unless we set them manually per file.

Original SVG File: check

Swiftdraw generated sfsymcols check

Is there a way we can get swiftdraw to maintain the inserts from the original SVG that was generated from the figma design?

vladzz commented 1 year ago

move

emo

anodetamer commented 1 year ago

I face the same problem. How did you solve this?

swhitty commented 1 year ago

By default auto insets are applied, but you can supply your own. To remove all insets use:

--insets 0,0,0,0

vladzz commented 1 year ago

Thanks @swhitty but what if I just want it to replicate the insets from the original SVG? It doesn't seem to do that? The insets it adds with auto are completely different to the original file.

swhitty commented 1 year ago

You should use --insets 0,0,0,0 to align the edges of the original SVG to the SFSymbol guides.

Let's use key.svg as an example. The SVG includes a canvas size of 256x256. The paths within the SVG are positioned within the canvas like so;

key

--insets auto

By default SwiftDraw uses --insets auto to detect these insets and align those positions to the SFSymbol guides;

key-auto

SwiftDraw will output the auto insets it detects to the terminal: Alignment: --insets 37.2563,26,32,32.6497

--insets 0,0,0,0

Supplying --insets 0,0,0,0 aligns the edges of the SVG canvas to these guides, preserving the padding within the SVG itself.

key-zero