26
Oct
2021
List Available Fonts in SwiftUI
Reading time: 1 min
This quick recipe show how to list and display all the fonts that are available by default in your iOS/MacOS app.
The end result looks like this:
Here's the code:
let allFontNames = UIFont.familyNames
.flatMap { UIFont.fontNames(forFamilyName: $0) }
var body: some View {
List(allFontNames, id: \.self) { name in
Text(name)
.font(Font.custom(name, size: 12))
}
}