commit | 20c8fe37329cb18826f90159ce4ee445079e2e46 | [log] [tgz] |
---|---|---|
author | randallli <randallli@google.com> | Tue Nov 29 22:02:09 2016 |
committer | randallli <randallli@google.com> | Tue Nov 29 22:02:09 2016 |
tree | 7efb4681d478132ec1b8e9c71999268322fdb578 | |
parent | 504c00535ed9d985928bf43bfd6c3bed4ee2a1ce [diff] |
changed min os to 7
#FontDiskLoader
Registers a single custom font asset from disk
In order to use custom fonts on iOS the font assets need to be registered before they can be used. Font Disk Loader lazily registers your custom fonts.
To add this component to your Xcode project using CocoaPods, add the following to your Podfile
:
pod 'MDFFontDiskLoader'
Then, run the following command:
pod install
Before using Font Disk Loader, you'll need to import it:
#import "MaterialFontDiskLoader.h"
import MDFFontDiskLoader
Make sure to add your font (or the bundle it is in) to your app target. The FontDiskLoader will lazy register the font using a CoreText API so adding a the font to your info.plist
is not necessary. All you need to do is initialize the loader with the font name and url to the file and ask for the font.
MDFFontDiskLoader *fontDiskLoader = [[MDFFontDiskLoader alloc] initWithFontName:nameOfFontInFile URL:fontURLOnDisk]; UIFont *font = [fontDiskLoader fontOfSize:16];
let fontLoader = MDFFontDiskLoader.init(fontName: nameOfFontInFile, fontURL: fontURLOnDisk); let myFont:UIFont = fontLoader.fontOfSize(16)!;