Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Samples/dash.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion SwiftDraw/Renderer.SFSymbol.swift
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ extension SFSymbolRenderer {

static func makeTransformation(from source: LayerTree.Rect,
to destination: LayerTree.Rect) -> LayerTree.Transform.Matrix {
let scale = destination.height / source.height
let scale = min(destination.width / source.width, destination.height / source.height)
let scaleMidX = source.midX * scale
let scaleMidY = source.midY * scale
let tx = destination.midX - scaleMidX
Expand Down
17 changes: 17 additions & 0 deletions SwiftDrawTests/Renderer.SFSymbolTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,23 @@ final class RendererSFSymbolTests: XCTestCase {
template.black.contents.paths.isEmpty
)
}

func testWidthGreaterThanHeightSymbol() throws {
// This svg has a width of 24, but a height of 4. When scaling in SFSymbolRenderer makeTransformation
// the height was being used to create scale causing the width to be 440 instead of 108.
let url = try Bundle.test.url(forResource: "dash.svg")
let template = try SFSymbolTemplate.parse(
SFSymbolRenderer.render(fileURL: url)
)

XCTAssertTrue(
template.regular.bounds.size.width == 108.0
)
XCTAssertTrue(
template.regular.bounds.size.height == 70.0
)

}

#if canImport(CoreGraphics)
func testStrokeSymbol() throws {
Expand Down