Signed-off-by: Matt Bruce <mbrucedogs@gmail.com>

This commit is contained in:
Matt Bruce 2025-09-09 13:18:26 -05:00
parent 6ae6cd9c42
commit 9cd84e1cac
3 changed files with 35 additions and 13 deletions

4
PRD.md
View File

@ -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 - **Opacity controls**: Separate opacity for clock digits and overlays
- **Random color mode**: Automatically changes digit color every minute - **Random color mode**: Automatically changes digit color every minute
- **Preset themes**: Quick "Night" (black/white) and "Day" (white/black) themes - **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 weight options**: Ultra Light, Thin, Light, Regular, Medium, Semibold, Bold, Heavy, Black
- **Font design choices**: Default, Serif, Rounded, Monospaced designs - **Font design choices**: Default, Serif, Rounded, Monospaced designs
- **Live font preview**: Real-time preview of font changes in settings - **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 - **Perfect centering**: Each digit is centered within its fixed-width container
### Font Customization System ### 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 - **Weight variations**: 9 weight options from Ultra Light to Black
- **Design choices**: Default, Serif, Rounded, Monospaced designs - **Design choices**: Default, Serif, Rounded, Monospaced designs
- **Live preview**: Real-time font preview in settings interface - **Live preview**: Real-time font preview in settings interface

View File

@ -128,10 +128,18 @@ enum FontUtils {
/// - Returns: SwiftUI Font /// - Returns: SwiftUI Font
static func fontFamily(_ family: String) -> Font { static func fontFamily(_ family: String) -> Font {
switch family { switch family {
case "San Francisco":
return .system(.body, design: .default)
case "System": case "System":
return .system(.body, design: .default) 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": case "Monaco":
return .system(.body, design: .monospaced) return .system(.body, design: .monospaced)
case "Courier": case "Courier":
@ -200,6 +208,8 @@ enum FontUtils {
weight: String, weight: String,
design: String design: String
) -> Font { ) -> Font {
// For system fonts, use the system font with design
if family == "System" || family == "Monaco" || family == "Courier" {
return .system( return .system(
size: size, size: size,
weight: fontWeight(weight), weight: fontWeight(weight),
@ -207,6 +217,12 @@ enum FontUtils {
) )
} }
// 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 /// Calculate the maximum width for any two-digit combination
/// - Parameters: /// - Parameters:
/// - font: The font to measure with /// - font: The font to measure with
@ -305,12 +321,18 @@ enum FontUtils {
uiDesign = .default uiDesign = .default
} }
// For system fonts, use system font descriptor with design
if family == "System" || family == "Monaco" || family == "Courier" {
let descriptor = UIFontDescriptor.preferredFontDescriptor(withTextStyle: .body) let descriptor = UIFontDescriptor.preferredFontDescriptor(withTextStyle: .body)
.withDesign(uiDesign) ?? 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 /// Measure text size with given font
/// - Parameters: /// - Parameters:
/// - text: Text to measure /// - text: Text to measure

View File

@ -55,7 +55,7 @@ struct ClockSettingsView: View {
private struct FontSection: View { private struct FontSection: View {
@Binding var style: ClockStyle @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 fontWeights = ["Ultra Light", "Thin", "Light", "Regular", "Medium", "Semibold", "Bold", "Heavy", "Black"]
private let fontDesigns = ["Default", "Serif", "Rounded", "Monospaced"] private let fontDesigns = ["Default", "Serif", "Rounded", "Monospaced"]