diff --git a/PRD.md b/PRD.md index a67b46c..bd0919e 100644 --- a/PRD.md +++ b/PRD.md @@ -31,7 +31,7 @@ TheNoiseClock is a SwiftUI-based iOS application that combines a customizable di - **Opacity controls**: Separate opacity for clock digits and overlays - **Random color mode**: Automatically changes digit color every minute - **Preset themes**: Quick "Night" (black/white) and "Day" (white/black) themes -- **Font family selection**: Choose from System, San Francisco, Monaco, Courier fonts +- **Font family selection**: Choose from System, Helvetica, Arial, Times New Roman, Georgia, Verdana, Monaco, Courier fonts - **Font weight options**: Ultra Light, Thin, Light, Regular, Medium, Semibold, Bold, Heavy, Black - **Font design choices**: Default, Serif, Rounded, Monospaced designs - **Live font preview**: Real-time preview of font changes in settings @@ -111,7 +111,7 @@ TheNoiseClock is a SwiftUI-based iOS application that combines a customizable di - **Perfect centering**: Each digit is centered within its fixed-width container ### Font Customization System -- **Font family selection**: System, San Francisco, Monaco, Courier options +- **Font family selection**: System, Helvetica, Arial, Times New Roman, Georgia, Verdana, Monaco, Courier options - **Weight variations**: 9 weight options from Ultra Light to Black - **Design choices**: Default, Serif, Rounded, Monospaced designs - **Live preview**: Real-time font preview in settings interface diff --git a/TheNoiseClock/Core/Utilities/FontUtils.swift b/TheNoiseClock/Core/Utilities/FontUtils.swift index f2c3433..fa89169 100644 --- a/TheNoiseClock/Core/Utilities/FontUtils.swift +++ b/TheNoiseClock/Core/Utilities/FontUtils.swift @@ -128,10 +128,18 @@ enum FontUtils { /// - Returns: SwiftUI Font static func fontFamily(_ family: String) -> Font { switch family { - case "San Francisco": - return .system(.body, design: .default) case "System": return .system(.body, design: .default) + case "Helvetica": + return .custom("Helvetica", size: 17) + case "Arial": + return .custom("Arial", size: 17) + case "Times New Roman": + return .custom("Times New Roman", size: 17) + case "Georgia": + return .custom("Georgia", size: 17) + case "Verdana": + return .custom("Verdana", size: 17) case "Monaco": return .system(.body, design: .monospaced) case "Courier": @@ -200,11 +208,19 @@ enum FontUtils { weight: String, design: String ) -> Font { - return .system( - size: size, - weight: fontWeight(weight), - design: fontDesign(design) - ) + // For system fonts, use the system font with design + if family == "System" || family == "Monaco" || family == "Courier" { + return .system( + size: size, + weight: fontWeight(weight), + design: fontDesign(design) + ) + } + + // For custom fonts, create with weight + let fontWeight = fontWeight(weight) + return .custom(family, size: size) + .weight(fontWeight) } /// Calculate the maximum width for any two-digit combination @@ -305,10 +321,16 @@ enum FontUtils { uiDesign = .default } - let descriptor = UIFontDescriptor.preferredFontDescriptor(withTextStyle: .body) - .withDesign(uiDesign) ?? UIFontDescriptor.preferredFontDescriptor(withTextStyle: .body) + // For system fonts, use system font descriptor with design + if family == "System" || family == "Monaco" || family == "Courier" { + let descriptor = UIFontDescriptor.preferredFontDescriptor(withTextStyle: .body) + .withDesign(uiDesign) ?? UIFontDescriptor.preferredFontDescriptor(withTextStyle: .body) + + return UIFont(descriptor: descriptor.addingAttributes([.traits: [UIFontDescriptor.TraitKey.weight: uiWeight]]), size: size) + } - return UIFont(descriptor: descriptor.addingAttributes([.traits: [UIFontDescriptor.TraitKey.weight: uiWeight]]), size: size) + // For custom fonts, create with family name and weight + return UIFont(name: family, size: size) ?? UIFont.systemFont(ofSize: size, weight: uiWeight) } /// Measure text size with given font diff --git a/TheNoiseClock/Views/Clock/ClockSettingsView.swift b/TheNoiseClock/Views/Clock/ClockSettingsView.swift index c0937bc..e3ad5f4 100644 --- a/TheNoiseClock/Views/Clock/ClockSettingsView.swift +++ b/TheNoiseClock/Views/Clock/ClockSettingsView.swift @@ -55,7 +55,7 @@ struct ClockSettingsView: View { private struct FontSection: View { @Binding var style: ClockStyle - private let fontFamilies = ["System", "San Francisco", "Monaco", "Courier"] + private let fontFamilies = ["System", "Arial", "Courier", "Georgia", "Helvetica", "Monaco", "Times New Roman", "Verdana"] private let fontWeights = ["Ultra Light", "Thin", "Light", "Regular", "Medium", "Semibold", "Bold", "Heavy", "Black"] private let fontDesigns = ["Default", "Serif", "Rounded", "Monospaced"]