UIFontSerialization
encodes and decodes between UIFont
and Postscript font data, following the API conventions of Foundation's NSJSONSerialization
class.
NSURL *fontFileURL = [[NSBundle mainBundle] URLForResource:@"font" withExtension:@"tty"];
NSData *data = [NSData dataWithContentsOfURL:fontFileURL];
UIFont *font = [UIFontSerialization fontWithData:data error:nil];
UIFont *font = [UIFont systemFontOfSize:24]
NSData *data = [UIFontSerialization dataWithFont:font error:nil];
Mattt Thompson
UIFontSerialization is available under the MIT license. See the LICENSE file for more info.