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 import Foundation
enum FontFamilies: String, CaseIterable/*, CustomStringConvertible*/ { enum Fonts: String, CaseIterable/*, CustomStringConvertible*/ {
case mesloLGSNF = "MesloLGS NF" case mesloLGSNF = "MesloLGS-NF-Regular"
case sfMono = "SF Mono" case sfMono = "SFMono-Regular"
case cascadiaMono case cascadiaMono = "CascadiaMono-Regular"
case geistMonoNF case geistMonoNF = "GeistMonoNFM-Regular"
case jetbrainsMonoNF case jetbrainsMonoNF = "JetBrainsMonoNFM-Regular"
case comicSans case comicSans = "ComicSansMS"
case comicMono 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() { func loadFonts() {
var customFonts: [UIFont] = []
for family in UIFont.familyNames.sorted() { for family in UIFont.familyNames.sorted() {
let names = UIFont.fontNames(forFamilyName: family) 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 { guard let customFont = UIFont(name: names[0], size: UIFont.systemFontSize) else {
fatalError() fatalError()
} }