diff --git a/Samples.bundle/cjk-fallback.svg b/Samples.bundle/cjk-fallback.svg new file mode 100644 index 0000000..8b2adfb --- /dev/null +++ b/Samples.bundle/cjk-fallback.svg @@ -0,0 +1,6 @@ + + + 敏捷的棕色狐狸跳过懒狗,窗前明月光照桌上旧书 + いろはにほへとちりぬるを わかよたれそ つねならむ + 다람쥐 헌 쳇바퀴에 타고파, 한글도 잘 보이나요? + diff --git a/SwiftDraw/Sources/Utilities/CGPath+Segment.swift b/SwiftDraw/Sources/Utilities/CGPath+Segment.swift index a200e3c..3da65ee 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