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
- **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

View File

@ -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

View File

@ -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"]