From 0c31a7d7c5cd69c5046594a9a06140ccc771b547 Mon Sep 17 00:00:00 2001 From: neon443 <69979447+neon443@users.noreply.github.com> Date: Sun, 6 Jul 2025 16:24:02 +0100 Subject: [PATCH] got loading some custom fonts, only ones with one "name" inside the family --- ShhShell/Fonts/Fonts.swift | 20 ++++++++++++-------- ShhShell/Host/HostsManager.swift | 5 ++++- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/ShhShell/Fonts/Fonts.swift b/ShhShell/Fonts/Fonts.swift index 775fbcc..f108225 100644 --- a/ShhShell/Fonts/Fonts.swift +++ b/ShhShell/Fonts/Fonts.swift @@ -7,12 +7,16 @@ import Foundation -enum FontFamilies: String, CaseIterable/*, CustomStringConvertible*/ { - case mesloLGSNF = "MesloLGS NF" - case sfMono = "SF Mono" - case cascadiaMono - case geistMonoNF - case jetbrainsMonoNF - case comicSans - case comicMono +enum Fonts: String, CaseIterable/*, CustomStringConvertible*/ { + case mesloLGSNF = "MesloLGS-NF-Regular" + case sfMono = "SFMono-Regular" + case cascadiaMono = "CascadiaMono-Regular" + case geistMonoNF = "GeistMonoNFM-Regular" + case jetbrainsMonoNF = "JetBrainsMonoNFM-Regular" + case comicSans = "ComicSansMS" + case comicMono = "ComicMono" + + static var fontNames: [String] { + return Fonts.allCases.map { $0.rawValue } + } } diff --git a/ShhShell/Host/HostsManager.swift b/ShhShell/Host/HostsManager.swift index 0e14368..5bec558 100644 --- a/ShhShell/Host/HostsManager.swift +++ b/ShhShell/Host/HostsManager.swift @@ -31,9 +31,12 @@ class HostsManager: ObservableObject, @unchecked Sendable { } func loadFonts() { + var customFonts: [UIFont] = [] for family in UIFont.familyNames.sorted() { let names = UIFont.fontNames(forFamilyName: family) - print("family: \(family), name: \(names)") + if Fonts.fontNames.contains(names) { + print(family) + } guard let customFont = UIFont(name: names[0], size: UIFont.systemFontSize) else { fatalError() }