From 87c66136ac3fbe017e75b4086a9633c3eb9c94c5 Mon Sep 17 00:00:00 2001 From: Yu Sung Date: Fri, 23 Jan 2026 02:44:18 +0900 Subject: [PATCH] =?UTF-8?q?=EC=95=B1=20=EC=96=B8=EC=96=B4=20=EC=84=A4?= =?UTF-8?q?=EC=A0=95=EC=9D=B4=20=ED=95=9C=EA=B5=AD=EC=96=B4("ko")=EC=9D=B4?= =?UTF-8?q?=EB=A9=B4=20Pretendard=20=ED=8F=B0=ED=8A=B8=20=EA=B7=B8=20?= =?UTF-8?q?=EC=99=B8=EC=97=90=EB=8A=94=20=EC=8B=9C=EC=8A=A4=ED=85=9C=20?= =?UTF-8?q?=ED=8F=B0=ED=8A=B8=ED=95=98=EB=8A=94=20FontModifier=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Extensions/KoreanFontModifier.swift | 43 +++++++++++++++++++ SodaLive/Sources/Main/Home/TabButton.swift | 6 +-- 2 files changed, 46 insertions(+), 3 deletions(-) create mode 100644 SodaLive/Sources/Extensions/KoreanFontModifier.swift diff --git a/SodaLive/Sources/Extensions/KoreanFontModifier.swift b/SodaLive/Sources/Extensions/KoreanFontModifier.swift new file mode 100644 index 0000000..c85e7d4 --- /dev/null +++ b/SodaLive/Sources/Extensions/KoreanFontModifier.swift @@ -0,0 +1,43 @@ +// +// KoreanFontModifier.swift +// SodaLive +// +// Created by klaus on 1/23/26. +// + +import SwiftUI + +struct KoreanFontModifier: ViewModifier { + @Environment(\.locale) private var locale + let size: CGFloat + let weight: SwiftUI.Font.Weight + + private func resolvedLanguageCode() -> String? { + if let raw = UserDefaults.standard.string(forKey: "app.language"), + let option = LanguageOption(rawValue: raw), + option != .system { + return option.rawValue + } + return locale.language.languageCode?.identifier + } + + func body(content: Content) -> some View { + if resolvedLanguageCode() == "ko" { + let name: String = switch weight { + case .bold: "Pretendard-Bold" + case .medium: "Pretendard-Medium" + case .light: "Pretendard-Light" + default: "Pretendard-Regular" + } + content.font(.custom(name, 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(KoreanFontModifier(size: size, weight: weight)) + } +} diff --git a/SodaLive/Sources/Main/Home/TabButton.swift b/SodaLive/Sources/Main/Home/TabButton.swift index 72f07fa..e989dcd 100644 --- a/SodaLive/Sources/Main/Home/TabButton.swift +++ b/SodaLive/Sources/Main/Home/TabButton.swift @@ -12,7 +12,7 @@ struct TabButton: View { let title: LocalizedStringResource let action: () -> Void let image: () -> String - let fontName: () -> String + let fontWeight: () -> SwiftUI.Font.Weight let color: () -> Color let width: CGFloat @@ -21,7 +21,7 @@ struct TabButton: View { Image(image()) Text(title) - .font(.custom(fontName(), size: 10)) + .appFont(size: 10, weight: fontWeight()) .foregroundColor(color()) } .frame(width: width) @@ -37,7 +37,7 @@ struct TabButton_Previews: PreviewProvider { title: "라이브", action: {}, image: { "ic_tabbar_live_selected" }, - fontName: { Font.bold.rawValue }, + fontWeight: { .bold }, color: { Color(hex: "3bb9f1") }, width: UIScreen.main.bounds.width / 4 )