chore: reverted font size 504d5672
Steve · 2025-12-25 19:37 3 file(s) · +10 −42
Titan/Settings/ThemeSettings.swift +1 −15
52 52
    /// The font design for content
53 53
    @Published var fontDesign: FontDesignOption = .monospaced
54 54
55 -
    /// The base font size for content (default 16pt)
56 -
    @Published var baseFontSize: CGFloat = 16
57 -
58 55
    /// The home page URL that the browser navigates to on launch and when pressing Home
59 56
    @AppStorage("homePage") var homePage: String = "gemini://geminiprotocol.net/"
60 57
61 58
    /// Key for persisting accent color hex value
62 59
    private static let accentColorKey = "accentColorHex"
63 -
    private static let backgroundColorKey = "backgroundColorHex"
60 +
    private static let backgroundColorKey = "backgroundColorKey"
64 61
    private static let textColorKey = "textColorHex"
65 62
    private static let fontDesignKey = "fontDesign"
66 -
    private static let baseFontSizeKey = "baseFontSize"
67 63
68 64
    init() {
69 65
        if let hex = UserDefaults.standard.string(forKey: Self.accentColorKey),
82 78
           let font = FontDesignOption(rawValue: fontRaw) {
83 79
            fontDesign = font
84 80
        }
85 -
        let savedFontSize = UserDefaults.standard.double(forKey: Self.baseFontSizeKey)
86 -
        if savedFontSize > 0 {
87 -
            baseFontSize = savedFontSize
88 -
        }
89 81
    }
90 82
91 83
    /// Sets all accent colors to the given color and persists the choice
121 113
    func setFontDesign(_ font: FontDesignOption) {
122 114
        fontDesign = font
123 115
        UserDefaults.standard.set(font.rawValue, forKey: Self.fontDesignKey)
124 -
    }
125 -
126 -
    /// Sets the base font size and persists the choice
127 -
    func setBaseFontSize(_ size: CGFloat) {
128 -
        baseFontSize = size
129 -
        UserDefaults.standard.set(Double(size), forKey: Self.baseFontSizeKey)
130 116
    }
131 117
}
132 118
Titan/Views/SettingsView.swift +0 −12
14 14
    @State private var selectedBackgroundColor: Color = Color(UIColor.systemBackground)
15 15
    @State private var selectedTextColor: Color = Color(UIColor.label)
16 16
    @State private var selectedFontDesign: FontDesignOption = .monospaced
17 -
    @State private var selectedFontSize: Double = 16
18 17
19 18
    var body: some View {
20 19
        NavigationStack {
39 38
                            Text(option.rawValue).tag(option)
40 39
                        }
41 40
                    }
42 -
                    VStack(alignment: .leading) {
43 -
                        HStack {
44 -
                            Text("Font Size")
45 -
                            Spacer()
46 -
                            Text("\(Int(selectedFontSize))pt")
47 -
                                .foregroundColor(.secondary)
48 -
                        }
49 -
                        Slider(value: $selectedFontSize, in: 12...24, step: 1)
50 -
                    }
51 41
                } header: {
52 42
                    Text("Appearance")
53 43
                } footer: {
69 59
                        themeSettings.setBackgroundColor(selectedBackgroundColor)
70 60
                        themeSettings.setTextColor(selectedTextColor)
71 61
                        themeSettings.setFontDesign(selectedFontDesign)
72 -
                        themeSettings.setBaseFontSize(CGFloat(selectedFontSize))
73 62
                        dismiss()
74 63
                    }
75 64
                }
80 69
                selectedBackgroundColor = themeSettings.backgroundColor
81 70
                selectedTextColor = themeSettings.textColor
82 71
                selectedFontDesign = themeSettings.fontDesign
83 -
                selectedFontSize = Double(themeSettings.baseFontSize)
84 72
            }
85 73
        }
86 74
    }
Titan/Views/TitanContentView.swift +9 −15
7 7
8 8
struct PreformattedBlockView: View {
9 9
    let text: String
10 -
    let baseFontSize: CGFloat
11 10
12 -
    private var maxFontSize: CGFloat { baseFontSize * 0.75 }
11 +
    private let maxFontSize: CGFloat = 12
13 12
    private let charWidthRatio: CGFloat = 0.6 // Monospace char width ≈ 0.6 * font size
14 13
    private let lineHeightRatio: CGFloat = 1.2
15 14
72 71
        .padding(8)
73 72
    }
74 73
75 -
    private var fontSize: CGFloat { themeSettings.baseFontSize }
76 -
    private var heading1Size: CGFloat { fontSize * 1.75 }
77 -
    private var heading2Size: CGFloat { fontSize * 1.5 }
78 -
    private var heading3Size: CGFloat { fontSize * 1.25 }
79 -
80 74
    @ViewBuilder
81 75
    private func lineView(for line: TitanLine) -> some View {
82 76
        switch line {
83 77
        case .text(let text):
84 78
            Text(text)
85 -
                .font(.system(size: fontSize, design: themeSettings.fontDesign.fontDesign))
79 +
                .font(.system(.body, design: themeSettings.fontDesign.fontDesign))
86 80
                .foregroundColor(themeSettings.textColor)
87 81
88 82
        case .link(let url, let label):
90 84
                HStack(alignment:.top, spacing: 4) {
91 85
                    Text(label)
92 86
                        .multilineTextAlignment(.leading)
93 -
                        .font(.system(size: fontSize, design: themeSettings.fontDesign.fontDesign))
87 +
                        .font(.system(size: 14, design: themeSettings.fontDesign.fontDesign))
94 88
                }
95 89
            }
96 90
            .foregroundColor(themeSettings.linkColor)
98 92
99 93
        case .heading1(let text):
100 94
            Text(text)
101 -
                .font(.system(size: heading1Size, design: themeSettings.fontDesign.fontDesign))
95 +
                .font(.system(.title, design: themeSettings.fontDesign.fontDesign))
102 96
                .fontWeight(.bold)
103 97
                .foregroundColor(themeSettings.textColor)
104 98
                .padding(.top, 8)
105 99
106 100
        case .heading2(let text):
107 101
            Text(text)
108 -
                .font(.system(size: heading2Size, design: themeSettings.fontDesign.fontDesign))
102 +
                .font(.system(.title2, design: themeSettings.fontDesign.fontDesign))
109 103
                .fontWeight(.semibold)
110 104
                .foregroundColor(themeSettings.textColor)
111 105
                .padding(.top, 6)
112 106
113 107
        case .heading3(let text):
114 108
            Text(text)
115 -
                .font(.system(size: heading3Size, design: themeSettings.fontDesign.fontDesign))
109 +
                .font(.system(.title3, design: themeSettings.fontDesign.fontDesign))
116 110
                .fontWeight(.medium)
117 111
                .foregroundColor(themeSettings.textColor)
118 112
                .padding(.top, 4)
122 116
                Text("\u{2022}")
123 117
                Text(text)
124 118
            }
125 -
            .font(.system(size: fontSize, design: themeSettings.fontDesign.fontDesign))
119 +
            .font(.system(.body, design: themeSettings.fontDesign.fontDesign))
126 120
            .foregroundColor(themeSettings.textColor)
127 121
128 122
        case .quote(let text):
129 123
            Text(text)
130 -
                .font(.system(size: fontSize, design: themeSettings.fontDesign.fontDesign))
124 +
                .font(.system(.body, design: themeSettings.fontDesign.fontDesign))
131 125
                .italic()
132 126
                .foregroundColor(.secondary)
133 127
                .padding(.leading, 12)
134 128
135 129
        case .preformattedBlock(let text, _):
136 -
            PreformattedBlockView(text: text, baseFontSize: fontSize)
130 +
            PreformattedBlockView(text: text)
137 131
                .padding(.vertical, 4)
138 132
        }
139 133
    }