-
Notifications
You must be signed in to change notification settings - Fork 57
Open
Description
to reproduce, export a series of sfsymbol images based on the key.svg image in the test bundle. These all use identical 30px insets for the top and bottom, but use different values for the left and right:
$ INSETS="30,30,30,30" && swiftdraw SwiftDraw/Tests/Test.bundle/key.svg --format sfsymbol --insets $INSETS --ultralightInsets $INSETS --blackInsets $INSETS --output key.symbol.30.svg
$ INSETS="30,45,30,45" && swiftdraw SwiftDraw/Tests/Test.bundle/key.svg --format sfsymbol --insets $INSETS --ultralightInsets $INSETS --blackInsets $INSETS --output key.symbol.45.svg
$ INSETS="30,60,30,60" && swiftdraw SwiftDraw/Tests/Test.bundle/key.svg --format sfsymbol --insets $INSETS --ultralightInsets $INSETS --blackInsets $INSETS --output key.symbol.60.svg
Comparing the 30 and 40 variants gets a diff that you'd expect:
$ diff key.symbol.30.svg key.symbol.45.svg
24,29c24,29
< <path id="left-margin-Ultralight-S" d="M220,56 l0,110" />
< <path id="right-margin-Ultralight-S" d="M310,56 l0,110" />
< <path id="left-margin-Regular-S" d="M420,56 l0,110" />
< <path id="right-margin-Regular-S" d="M510,56 l0,110" />
< <path id="left-margin-Black-S" d="M620,56 l0,110" />
< <path id="right-margin-Black-S" d="M710,56 l0,110" />
---
> <path id="left-margin-Ultralight-S" d="M221,56 l0,110" />
> <path id="right-margin-Ultralight-S" d="M309,56 l0,110" />
> <path id="left-margin-Regular-S" d="M421,56 l0,110" />
> <path id="right-margin-Regular-S" d="M509,56 l0,110" />
> <path id="left-margin-Black-S" d="M621,56 l0,110" />
> <path id="right-margin-Black-S" d="M709,56 l0,110" />
However, there is no difference between the 30 and 45 variants, even though those margins should have moved again.
I believe the fix is to stop using min() in this section of code here:
% git diff SwiftDraw/Sources/Renderer/Renderer.SFSymbol.swift
diff --git a/SwiftDraw/Sources/Renderer/Renderer.SFSymbol.swift b/SwiftDraw/Sources/Renderer/Renderer.SFSymbol.swift
index 25539df..26f93be 100644
--- a/SwiftDraw/Sources/Renderer/Renderer.SFSymbol.swift
+++ b/SwiftDraw/Sources/Renderer/Renderer.SFSymbol.swift
@@ -523,9 +523,9 @@ private extension SFSymbolTemplate.Variant {
}
let midX = bounds.midX
- let newWidth = ((source.width * matrix.a) / 2) + 10
- left.x = min(left.x, midX - newWidth)
- right.x = max(right.x, midX + newWidth)
+ let newWidth = ((source.width * matrix.a) / 2)
+ left.x = midX - newWidth
+ right.x = midX + newWidth
}
}
left.x = min(left.x, midX - newWidth) |
Metadata
Metadata
Assignees
Labels
No labels