📌 설치된 모든 폰트 출력하기
func printAllFonts() {
for family in UIFont.familyNames {
print("Font Family: \(family)")
for fontName in UIFont.fontNames(forFamilyName: family) {
print(" - \(fontName)")
}
}
}
📌 사용 방법:
viewDidLoad()에 printAllFonts()를 호출
override func viewDidLoad() {
super.viewDidLoad()
printAllFonts()
}
// 출력 결과....
Font Family: Times New Roman
- TimesNewRomanPSMT
- TimesNewRomanPS-ItalicMT
- TimesNewRomanPS-BoldMT
- TimesNewRomanPS-BoldItalicMT
Font Family: Trebuchet MS
- TrebuchetMS
- TrebuchetMS-Italic
- TrebuchetMS-Bold
- Trebuchet-BoldItalic
Font Family: Verdana
- Verdana
- Verdana-Italic
- Verdana-Bold
- Verdana-BoldItalic
Font Family: Zapf Dingbats
- ZapfDingbatsITC
Font Family: Zapfino
- Zapfino
....
🔥 가끔 커스텀 폰트를 저장할 때, 이름이 잘못되어 적용이 안되는 경우 발생함
그럴때, 위와 같은 메서드를 통해 저장된 폰트를 확인하여 폰트 적용할 것