@@ -68,24 +68,24 @@ public struct SFSymbolRenderer {
6868
6969 template. svg. styles = image. styles. map ( makeSymbolStyleSheet)
7070
71- let boundsRegular = try makeBounds ( svg: image, auto: Self . makeBounds ( for: pathsRegular) , for: . regular)
71+ let boundsRegular = try makeBounds ( svg: image, auto: Self . makeAutoBounds ( for: pathsRegular) , for: . regular)
7272 template. regular. appendPaths ( pathsRegular, from: boundsRegular)
7373
7474 if let ultralight = ultralight,
7575 let paths = Self . getPaths ( for: ultralight) {
76- let bounds = try makeBounds ( svg: ultralight, auto: Self . makeBounds ( for: paths) , for: . ultralight)
76+ let bounds = try makeBounds ( svg: ultralight, isRegularSVG : false , auto: Self . makeAutoBounds ( for: paths) , for: . ultralight)
7777 template. ultralight. appendPaths ( paths, from: bounds)
7878 } else {
79- let bounds = try makeBounds ( svg: image, auto: Self . makeBounds ( for: pathsRegular) , for: . ultralight)
79+ let bounds = try makeBounds ( svg: image, auto: Self . makeAutoBounds ( for: pathsRegular) , for: . ultralight)
8080 template. ultralight. appendPaths ( pathsRegular, from: bounds)
8181 }
8282
8383 if let black = black,
8484 let paths = Self . getPaths ( for: black) {
85- let bounds = try makeBounds ( svg: black, auto: Self . makeBounds ( for: paths) , for: . black)
85+ let bounds = try makeBounds ( svg: black, isRegularSVG : false , auto: Self . makeAutoBounds ( for: paths) , for: . black)
8686 template. black. appendPaths ( paths, from: bounds)
8787 } else {
88- let bounds = try makeBounds ( svg: image, auto: Self . makeBounds ( for: pathsRegular) , for: . black)
88+ let bounds = try makeBounds ( svg: image, auto: Self . makeAutoBounds ( for: pathsRegular) , for: . black)
8989 template. black. appendPaths ( pathsRegular, from: bounds)
9090 }
9191
@@ -138,8 +138,8 @@ extension SFSymbolRenderer {
138138 }
139139 }
140140
141- func makeBounds( svg: DOM . SVG , auto: LayerTree . Rect , for variant: Variant ) throws -> LayerTree . Rect {
142- let insets = getInsets ( for: variant)
141+ func makeBounds( svg: DOM . SVG , isRegularSVG : Bool = true , auto: LayerTree . Rect , for variant: Variant ) throws -> LayerTree . Rect {
142+ let insets = getInsets ( for: isRegularSVG ? . regular : variant)
143143 let width = LayerTree . Float ( svg. width)
144144 let height = LayerTree . Float ( svg. height)
145145 let top = insets. top ?? Double ( auto. minY)
@@ -257,14 +257,18 @@ extension SFSymbolRenderer {
257257#endif
258258 }
259259
260- static func makeBounds ( for paths: [ SymbolPath ] ) -> LayerTree . Rect {
260+ static func makeAutoBounds ( for paths: [ SymbolPath ] ) -> LayerTree . Rect {
261261 var min = LayerTree . Point. maximum
262262 var max = LayerTree . Point. minimum
263263 for p in paths {
264264 let bounds = p. path. bounds
265265 min = min. minimum ( combining: . init( bounds. minX, bounds. minY) )
266266 max = max. maximum ( combining: . init( bounds. maxX, bounds. maxY) )
267267 }
268+
269+ min. x -= 10
270+ max. x += 10
271+
268272 return LayerTree . Rect (
269273 x: min. x,
270274 y: min. y,
@@ -523,9 +527,9 @@ private extension SFSymbolTemplate.Variant {
523527 }
524528
525529 let midX = bounds. midX
526- let newWidth = ( ( source. width * matrix. a) / 2 ) + 10
527- left. x = min ( left . x , midX - newWidth)
528- right. x = max ( right . x , midX + newWidth)
530+ let newWidth = ( ( source. width * matrix. a) / 2 )
531+ left. x = midX - newWidth
532+ right. x = midX + newWidth
529533 }
530534}
531535
0 commit comments