got loading some custom fonts, only ones with one "name" inside the family

This commit is contained in:
neon443
2025-07-06 16:24:02 +01:00
parent 0d53ccc3bc
commit 0c31a7d7c5
2 changed files with 16 additions and 9 deletions

View File

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

View File

@@ -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()
}