When using custom fonts in your iOS project you'll need the correct font name when you work with UIFont(name:String, size:CGFloat)
. The font name is not always the same as the file name, so with this extension you can easily find the name of your custom font.
This extension on UIFont enumerates all the available font families on the device with their font names.
Import the module in the file where you want to use the class method.
import UIFont_Enumerate
Then you just call the class method enumerateFonts
.
UIFont.enumerateFonts()
This will result in the following output in the console.
[UIFont] Start enumerating 75 font families.
1. Font family = Thonburi
- 1) Font name = Thonburi-Bold
- 2) Font name = Thonburi
- 3) Font name = Thonburi-Light
...
75. Font family = Bodoni 72 Smallcaps
- 1) Font name = BodoniSvtyTwoSCITCTT-Book
[UIFont] End enumerating
UIFont-Enumerate is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "UIFont-Enumerate"
Frederik Jacques, [email protected]
UIFont-Enumerate is available under the MIT license. See the LICENSE file for more info.