Skip to content

Commit ed239ac

Browse files
committed
Only wind fill-rule: evenOdd
1 parent e92302a commit ed239ac

File tree

1 file changed

+19
-13
lines changed

1 file changed

+19
-13
lines changed

SwiftDraw/Renderer.SFSymbol.swift

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -195,16 +195,19 @@ extension SFSymbolRenderer {
195195
for c in layer.contents {
196196
switch c {
197197
case let .shape(shape, stroke, fill):
198-
if let path = makePath(for: shape,
199-
stoke: stroke,
200-
fill: fill,
201-
preserve: isSFSymbolLayer)?.applying(matrix: ctm) {
198+
199+
if let fillPath = makeFillPath(for: shape, fill: fill, preserve: isSFSymbolLayer) {
202200
if fill.rule == .evenodd {
203-
paths.append(SymbolPath(class: symbolClass, path: path.makeNonZero()))
201+
paths.append(SymbolPath(class: symbolClass, path: fillPath.applying(matrix: ctm).makeNonZero()))
204202
} else {
205-
paths.append(SymbolPath(class: symbolClass, path: path))
203+
paths.append(SymbolPath(class: symbolClass, path: fillPath.applying(matrix: ctm)))
206204
}
207205
}
206+
207+
if let strokePath = makeStrokePath(for: shape, stroke: stroke, preserve: isSFSymbolLayer) {
208+
paths.append(SymbolPath(class: symbolClass, path: strokePath.applying(matrix: ctm)))
209+
}
210+
208211
case let .text(text, point, attributes):
209212
if let path = makePath(for: text, at: point, with: attributes) {
210213
paths.append(SymbolPath(class: symbolClass, path: path.applying(matrix: ctm)))
@@ -219,18 +222,21 @@ extension SFSymbolRenderer {
219222
return paths
220223
}
221224

222-
static func makePath(for shape: LayerTree.Shape,
223-
stoke: LayerTree.StrokeAttributes,
224-
fill: LayerTree.FillAttributes,
225-
preserve: Bool) -> LayerTree.Path? {
226-
225+
static func makeFillPath(for shape: LayerTree.Shape,
226+
fill: LayerTree.FillAttributes,
227+
preserve: Bool) -> LayerTree.Path? {
227228
if preserve || (fill.fill != .none && fill.opacity > 0) {
228229
return shape.path
229230
}
231+
return nil
232+
}
230233

231-
if preserve || (stoke.color != .none && stoke.width > 0) {
234+
static func makeStrokePath(for shape: LayerTree.Shape,
235+
stroke: LayerTree.StrokeAttributes,
236+
preserve: Bool) -> LayerTree.Path? {
237+
if preserve || (stroke.color != .none && stroke.width > 0) {
232238
#if canImport(CoreGraphics)
233-
return expandOutlines(for: shape.path, stroke: stoke)
239+
return expandOutlines(for: shape.path, stroke: stroke)
234240
#else
235241
print("Warning:", "expanding stroke outlines requires macOS.", to: &.standardError)
236242
return nil

0 commit comments

Comments
 (0)