File tree Expand file tree Collapse file tree 3 files changed +21
-1
lines changed Expand file tree Collapse file tree 3 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -266,7 +266,7 @@ extension SFSymbolRenderer {
266266
267267 static func makeTransformation( from source: LayerTree . Rect ,
268268 to destination: LayerTree . Rect ) -> LayerTree . Transform . Matrix {
269- let scale = destination. height / source. height
269+ let scale = min ( destination. width / source . width , destination . height / source. height)
270270 let scaleMidX = source. midX * scale
271271 let scaleMidY = source. midY * scale
272272 let tx = destination. midX - scaleMidX
Original file line number Diff line number Diff line change @@ -54,6 +54,23 @@ final class RendererSFSymbolTests: XCTestCase {
5454 template. black. contents. paths. isEmpty
5555 )
5656 }
57+
58+ func testWidthGreaterThanHeightSymbol( ) throws {
59+ // This svg has a width of 24, but a height of 4. When scaling in SFSymbolRenderer makeTransformation
60+ // the height was being used to create scale causing the width to be 440 instead of 108.
61+ let url = try Bundle . test. url ( forResource: " dash.svg " )
62+ let template = try SFSymbolTemplate . parse (
63+ SFSymbolRenderer . render ( fileURL: url)
64+ )
65+
66+ XCTAssertTrue (
67+ template. regular. bounds. size. width == 108.0
68+ )
69+ XCTAssertTrue (
70+ template. regular. bounds. size. height == 70.0
71+ )
72+
73+ }
5774
5875 #if canImport(CoreGraphics)
5976 func testStrokeSymbol( ) throws {
You can’t perform that action at this time.
0 commit comments