일본어 폰트 NotoSansJP로 변경
This commit is contained in:
@@ -16,7 +16,7 @@ private func resolvedLanguageCode(currentLocale: Locale) -> String? {
|
||||
return currentLocale.language.languageCode?.identifier
|
||||
}
|
||||
|
||||
private func appFontName(for weight: SwiftUI.Font.Weight) -> String {
|
||||
private func koreanFontName(for weight: SwiftUI.Font.Weight) -> String {
|
||||
switch weight {
|
||||
case .bold:
|
||||
return "Pretendard-Bold"
|
||||
@@ -29,15 +29,33 @@ private func appFontName(for weight: SwiftUI.Font.Weight) -> String {
|
||||
}
|
||||
}
|
||||
|
||||
private func japaneseFontName(for weight: SwiftUI.Font.Weight) -> String {
|
||||
switch weight {
|
||||
case .bold:
|
||||
return "NotoSansJP-Bold"
|
||||
case .medium:
|
||||
return "NotoSansJP-Medium"
|
||||
case .light:
|
||||
return "NotoSansJP-Light"
|
||||
default:
|
||||
return "NotoSansJP-Regular"
|
||||
}
|
||||
}
|
||||
|
||||
struct KoreanFontModifier: ViewModifier {
|
||||
@Environment(\.locale) private var locale
|
||||
let size: CGFloat
|
||||
let weight: SwiftUI.Font.Weight
|
||||
|
||||
func body(content: Content) -> some View {
|
||||
if resolvedLanguageCode(currentLocale: locale) == "ko" {
|
||||
content.font(.custom(appFontName(for: weight), size: size))
|
||||
} else {
|
||||
switch resolvedLanguageCode(currentLocale: locale) {
|
||||
case "ko":
|
||||
content.font(.custom(koreanFontName(for: weight), size: size))
|
||||
|
||||
case "ja":
|
||||
content.font(.custom(japaneseFontName(for: weight), size: size))
|
||||
|
||||
default:
|
||||
content.font(.system(size: size, weight: weight))
|
||||
}
|
||||
}
|
||||
@@ -52,8 +70,13 @@ extension View {
|
||||
extension Text {
|
||||
func appFont(size: CGFloat, weight: SwiftUI.Font.Weight = .regular) -> Text {
|
||||
if resolvedLanguageCode(currentLocale: .autoupdatingCurrent) == "ko" {
|
||||
return self.font(.custom(appFontName(for: weight), size: size))
|
||||
return self.font(.custom(koreanFontName(for: weight), size: size))
|
||||
}
|
||||
|
||||
if resolvedLanguageCode(currentLocale: .autoupdatingCurrent) == "ja" {
|
||||
return self.font(.custom(japaneseFontName(for: weight), size: size))
|
||||
}
|
||||
|
||||
return self.font(.system(size: size, weight: weight))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user