added font size

This commit is contained in:
neon443 committed 2025-07-09 20:04:55 +01:00
1 parent fa8a381ffb
commit 227b772885
2 files changed
+16 -1

No files matched your search

+6 -1
View File
@@ -20,6 +20,7 @@ class HostsManager: ObservableObject, @unchecked Sendable {
@Published var fonts: [UIFont] = [] @Published var fonts: [UIFont] = []
@Published var selectedFont: String = "SF Mono" @Published var selectedFont: String = "SF Mono"
@Published var fontSize: CGFloat = 12
var tint: SwiftUI.Color { var tint: SwiftUI.Color {
selectedTheme.ansi[selectedAnsi].suiColor selectedTheme.ansi[selectedAnsi].suiColor
@@ -36,13 +37,15 @@ class HostsManager: ObservableObject, @unchecked Sendable {
for family in UIFont.familyNames.sorted() { for family in UIFont.familyNames.sorted() {
if FontFamilies.allCasesRaw.contains(family) { if FontFamilies.allCasesRaw.contains(family) {
guard let family = FontFamilies(rawValue: family) else { return } guard let family = FontFamilies(rawValue: family) else { return }
guard let customFont = UIFont(name: family.description, size: UIFont.systemFontSize) else { return } guard let customFont = UIFont(name: family.description, size: fontSize) else { return }
customFonts.append(customFont) customFonts.append(customFont)
} }
} }
self.fonts = customFonts self.fonts = customFonts
userDefaults.synchronize()
self.selectedFont = userDefaults.string(forKey: "selectedFontName") ?? "Menlo" self.selectedFont = userDefaults.string(forKey: "selectedFontName") ?? "Menlo"
self.fontSize = CGFloat(userDefaults.double(forKey: "fontSize"))
} }
func selectFont(_ fontName: String) { func selectFont(_ fontName: String) {
@@ -53,6 +56,8 @@ class HostsManager: ObservableObject, @unchecked Sendable {
func saveFonts() { func saveFonts() {
userDefaults.set(selectedFont, forKey: "selectedFontName") userDefaults.set(selectedFont, forKey: "selectedFontName")
userDefaults.set(fontSize, forKey: "fontSize")
userDefaults.synchronize()
} }
func loadThemes() { func loadThemes() {
@@ -14,6 +14,16 @@ struct FontManagerView: View {
var body: some View { var body: some View {
List { List {
Slider(value: $hostsManager.fontSize, in: 1...15, step: 1) {
Label("Size", systemImage: "textformat.size")
} minimumValueLabel: {
Label("1", systemImage: "textformat.size.smaller")
} maximumValueLabel: {
Label("15", systemImage: "textformat.size.larger")
} onEditingChanged: { bool in
hostsManager.saveFonts()
}
ForEach(FontFamilies.allCasesRaw, id: \.self) { fontName in ForEach(FontFamilies.allCasesRaw, id: \.self) { fontName in
let selected = hostsManager.selectedFont == fontName let selected = hostsManager.selectedFont == fontName
Button() { Button() {
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.