diff --git a/SodaLive/Resources/Debug/SodaLive-dev-Info.plist b/SodaLive/Resources/Debug/SodaLive-dev-Info.plist index 85a0b7d..3cb7d32 100644 --- a/SodaLive/Resources/Debug/SodaLive-dev-Info.plist +++ b/SodaLive/Resources/Debug/SodaLive-dev-Info.plist @@ -989,6 +989,8 @@ NotoSansJP-Medium.ttf NotoSansJP-Light.ttf NotoSansJP-Regular.ttf + Pattaya-Regular.ttf + Phosphate-Solid.ttf UIBackgroundModes diff --git a/SodaLive/Resources/Font/Pattaya-Regular.ttf b/SodaLive/Resources/Font/Pattaya-Regular.ttf new file mode 100644 index 0000000..dc55eeb Binary files /dev/null and b/SodaLive/Resources/Font/Pattaya-Regular.ttf differ diff --git a/SodaLive/Resources/Font/Phosphate-Solid.ttf b/SodaLive/Resources/Font/Phosphate-Solid.ttf new file mode 100644 index 0000000..86c3fac Binary files /dev/null and b/SodaLive/Resources/Font/Phosphate-Solid.ttf differ diff --git a/SodaLive/Resources/Info.plist b/SodaLive/Resources/Info.plist index 2b117f2..b9518cc 100644 --- a/SodaLive/Resources/Info.plist +++ b/SodaLive/Resources/Info.plist @@ -989,6 +989,8 @@ NotoSansJP-Medium.ttf NotoSansJP-Light.ttf NotoSansJP-Regular.ttf + Pattaya-Regular.ttf + Phosphate-Solid.ttf UIBackgroundModes diff --git a/SodaLive/Sources/Extensions/FontModifier.swift b/SodaLive/Sources/Extensions/FontModifier.swift index 896380e..7b7e4bc 100644 --- a/SodaLive/Sources/Extensions/FontModifier.swift +++ b/SodaLive/Sources/Extensions/FontModifier.swift @@ -53,6 +53,12 @@ enum SodaTypography { } } +enum SodaFontFamily { + case localized + case pattaya + case phosphate +} + private func resolvedLanguageCode(currentLocale: Locale) -> String? { if let raw = UserDefaults.standard.string(forKey: "app.language"), let option = LanguageOption(rawValue: raw), @@ -88,49 +94,67 @@ private func japaneseFontName(for weight: SwiftUI.Font.Weight) -> String { } } +private func fontName(for family: SodaFontFamily, weight: SwiftUI.Font.Weight, locale: Locale) -> String? { + switch family { + case .localized: + switch resolvedLanguageCode(currentLocale: locale) { + case "ko": + return koreanFontName(for: weight) + case "ja": + return japaneseFontName(for: weight) + default: + return nil + } + case .pattaya: + return "Pattaya-Regular" + case .phosphate: + return "PhosphateSolid" + } +} + struct FontModifier: ViewModifier { @Environment(\.locale) private var locale let size: CGFloat let weight: SwiftUI.Font.Weight + let family: SodaFontFamily func body(content: Content) -> some View { - 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: + if let fontName = fontName(for: family, weight: weight, locale: locale) { + content.font(.custom(fontName, size: size)) + } else { content.font(.system(size: size, weight: weight)) } } } extension View { - func appFont(size: CGFloat, weight: SwiftUI.Font.Weight = .regular) -> some View { - self.modifier(FontModifier(size: size, weight: weight)) + func appFont( + size: CGFloat, + weight: SwiftUI.Font.Weight = .regular, + family: SodaFontFamily = .localized + ) -> some View { + self.modifier(FontModifier(size: size, weight: weight, family: family)) } - func appFont(_ typography: SodaTypography) -> some View { - appFont(size: typography.size, weight: typography.weight) + func appFont(_ typography: SodaTypography, family: SodaFontFamily = .localized) -> some View { + appFont(size: typography.size, weight: typography.weight, family: family) } } extension Text { - func appFont(size: CGFloat, weight: SwiftUI.Font.Weight = .regular) -> Text { - if resolvedLanguageCode(currentLocale: .autoupdatingCurrent) == "ko" { - return self.font(.custom(koreanFontName(for: weight), size: size)) - } - - if resolvedLanguageCode(currentLocale: .autoupdatingCurrent) == "ja" { - return self.font(.custom(japaneseFontName(for: weight), size: size)) + func appFont( + size: CGFloat, + weight: SwiftUI.Font.Weight = .regular, + family: SodaFontFamily = .localized + ) -> Text { + if let fontName = fontName(for: family, weight: weight, locale: .autoupdatingCurrent) { + return self.font(.custom(fontName, size: size)) } return self.font(.system(size: size, weight: weight)) } - func appFont(_ typography: SodaTypography) -> Text { - appFont(size: typography.size, weight: typography.weight) + func appFont(_ typography: SodaTypography, family: SodaFontFamily = .localized) -> Text { + appFont(size: typography.size, weight: typography.weight, family: family) } } diff --git a/SodaLive/Sources/Font/Font.swift b/SodaLive/Sources/Font/Font.swift index 89d4fce..e1f8965 100644 --- a/SodaLive/Sources/Font/Font.swift +++ b/SodaLive/Sources/Font/Font.swift @@ -13,4 +13,8 @@ enum Font: String { case preRegular = "Pretendard-Regular" case preLight = "Pretendard-Light" + + case pattayaRegular = "Pattaya-Regular" + + case phosphateSolid = "PhosphateSolid" }