swhitty / SwiftDraw

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

[PATCH] [Bug] update makeTransformation to consider svgs where width #20

Closed rcancro closed 1 year ago

rcancro commented 1 year ago

I was using the commandline tool to convert svg icons to SF Symbols. There were a few examples where the height of the icon is less than its width, causing the computation of the scale in Renderer.SFSymbol.swift makeTransformation to be too large. This resulted in the width of the symbol being incorrect.

I have included one of the icon svg tiles (dash.svg) and a test to make sure the bounds are computed properly. I’m not sure if this is the proper fix, but a repro step is very easy. Simply run:

SwiftDraw dash.svg —format sfsymbol

Here is the input file: dash

Here is the SF Symbol file before this patch: dash-symbol-broken

And here is the SF Symbol file afterwards: dash-symbol

codecov[bot] commented 1 year ago

Codecov Report

Patch coverage: 100.00% and no project coverage change.

Comparison is base (d803751) 85.36% compared to head (ecd3be1) 85.36%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #20 +/- ## ======================================= Coverage 85.36% 85.36% ======================================= Files 77 77 Lines 7009 7009 ======================================= Hits 5983 5983 Misses 1026 1026 ``` | [Impacted Files](https://app.codecov.io/gh/swhitty/SwiftDraw/pull/20?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Simon+Whitty) | Coverage Δ | | |---|---|---| | [SwiftDraw/Renderer.SFSymbol.swift](https://app.codecov.io/gh/swhitty/SwiftDraw/pull/20?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Simon+Whitty#diff-U3dpZnREcmF3L1JlbmRlcmVyLlNGU3ltYm9sLnN3aWZ0) | `83.54% <100.00%> (ø)` | |

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.

swhitty commented 1 year ago

0.14.0 includes the fix.