https://pretendard.jaemyeong.com
라이센스에 자유롭고 가독성도 괜찮은 Pretandard 폰트를 SPM으로 패키징 했다.
사용하기 위해서는 의존성 패키지에 추가하고 앱 진입점에서 폰트를 등록하여 사용하면 된다.
폰트의 등록 및 취소
public func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
// 폰트 등록
do {
try Pretendard.registerFonts()
} catch {
os_log(.error, "%@", String(describing: error))
}
return true
}
public func applicationWillTerminate(_ application: UIApplication) {
// 폰트 취소
do {
try Pretendard.unregisterFonts()
} catch {
os_log(.error, "%@", String(describing: error))
}
}
폰트의 사용
import Pretendard
let font: UIFont? = try .pretendardFont(ofSize: 14.0, weight: .regular)
또는
let font = UIFont(name: "Pretendard-Regular", size: 14.0)