I\'m currently working on an app that uses the \"ChalkboardSE-Regular\" font and my deployment target is 4.0+. This font was not available in 4.1 but it is supported in 4.3
print("Font families: %@", UIFont.familyNames)
For iOS9 / Swift 2.0, none of above won't work as the syntax changed a little. I also personally prefer to use extension (I choose to create one for UIFont, as it fits the best and modified @API answer as this was the best one):
extension UIFont {
static func availableFonts() {
// Get all fonts families
for family in UIFont.familyNames() {
NSLog("\(family)")
// Show all fonts for any given family
for name in UIFont.fontNamesForFamilyName(family) {
NSLog(" \(name)")
}
}
}
}
Now you can just call:
UIFont.availableFonts()
And it will tell you all the fonts in the form of
: Bangla Sangam MN
: BanglaSangamMN-Bold
: BanglaSangamMN
: Zapfino
: Zapfino
Hope it helps!
For objective-c
for (NSString *family in UIFont.familyNames) {
NSLog(@"family %@",family);
for (NSString *name in [UIFont fontNamesForFamilyName:family]) {
NSLog(@" name = %@",name);
}
}
Swift 4.x
UIFont.familyNames().sort( { $0 < $1 } ).forEach({ print("\($0)"); UIFont.fontNamesForFamilyName("\($0)").sort( { $0 < $1 } ).forEach({ print(" \($0)") }) })
If you use Swift you can print all fonts (see below). You can also check if the font exists.
for family in UIFont.familyNames {
print("\(family)")
for name in UIFont.fontNames(forFamilyName: family) {
print("\(name)")
}
}
Swift version:
UIFont.familyNames().sort( { $0 < $1 } ).forEach({ print("\($0)"); UIFont.fontNamesForFamilyName("\($0)").sort( { $0 < $1 } ).forEach({ print(" \($0)") }) })