From 3fbf694819f3aaf700282e672c7d6d0d45be9cc1 Mon Sep 17 00:00:00 2001 From: weixi Date: Fri, 5 Dec 2025 11:23:22 +0800 Subject: [PATCH 1/2] Use CoreText run font fallback for glyph paths --- SwiftDraw/Sources/Utilities/CGPath+Segment.swift | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/SwiftDraw/Sources/Utilities/CGPath+Segment.swift b/SwiftDraw/Sources/Utilities/CGPath+Segment.swift index a200e3cb..3da65eec 100644 --- a/SwiftDraw/Sources/Utilities/CGPath+Segment.swift +++ b/SwiftDraw/Sources/Utilities/CGPath+Segment.swift @@ -134,6 +134,8 @@ extension String { for idx in 0.. CTFont { + guard let value = attributes[kCTFontAttributeName] else { + return fallback + } + // CoreFoundation type bridging: ensure it's a CTFont before use. + if CFGetTypeID(value as CFTypeRef) == CTFontGetTypeID() { + return unsafeDowncast(value as AnyObject, to: CTFont.self) + } + return fallback + } } #endif From 14535c51c557f782851e4e0c2657b78d3eee02cb Mon Sep 17 00:00:00 2001 From: weixi Date: Mon, 8 Dec 2025 11:25:53 +0800 Subject: [PATCH 2/2] Add CJK fallback sample SVG --- Samples.bundle/cjk-fallback.svg | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 Samples.bundle/cjk-fallback.svg diff --git a/Samples.bundle/cjk-fallback.svg b/Samples.bundle/cjk-fallback.svg new file mode 100644 index 00000000..8b2adfbc --- /dev/null +++ b/Samples.bundle/cjk-fallback.svg @@ -0,0 +1,6 @@ + + + 敏捷的棕色狐狸跳过懒狗,窗前明月光照桌上旧书 + いろはにほへとちりぬるを わかよたれそ つねならむ + 다람쥐 헌 쳇바퀴에 타고파, 한글도 잘 보이나요? +