In the iOS 7 font list located here, http://support.apple.com/kb/HT5878, there is a section at the bottom with the heading "apps can download the following fonts if necessary".
What does this mean?
How does one include these fonts, and how is this different than including custom fonts?
This is interesting, it's an almost undocumented feature, but it seems ok to use and won't get your app rejected. Just trying to research this myself brought me to this question and not much else. All I could find that was documented is sample code showing how to use it: DownloadFont.
Demonstrates how to download fonts on demand on iOS 6 and later.
On iOS 6, we have added the capability for applications to download fonts on demand. Besides the fonts installed with iOS 6, applications can install a list of additional fonts as necessary.
The fonts listed are already licensed by Apple for use in iOS, however they aren't bundled with the standard iOS firmware due to the extra disk space usage. I would assume that this will continue to be how Apple provides new fonts (unless a part of the OS's UI uses it). Additionally, unlike adding fonts using the UIAppFonts
key in your Info.plist, after the font is downloaded, it is available for all apps to use.
Here's a simple example on how to asynchronously download a font and set it to a UITextView
.
- (void)asynchronouslySetFontName:(NSString *)fontName toTextView:(UITextView *)textView {
CGFloat size = 24.0f;
UIFont *font = [UIFont fontWithName:fontName size:size];
if (font && ([font.fontName compare:fontName] == NSOrderedSame || [font.familyName compare:fontName] == NSOrderedSame)) {
textView.font = font;
return;
}
NSMutableDictionary *attrs = [NSMutableDictionary dictionaryWithObject:fontName forKey:kCTFontNameAttribute];
CTFontDescriptorRef desc = CTFontDescriptorCreateWithAttributes((__bridge CFDictionaryRef)attrs);
NSMutableArray *descs = [NSMutableArray array];
[descs addObject:(__bridge id)desc];
CFRelease(desc);
__weak UITextView *weakTextView = textView;
CTFontDescriptorMatchFontDescriptorsWithProgressHandler((__bridge CFArrayRef)descs, NULL, ^(CTFontDescriptorMatchingState state, CFDictionaryRef progressParameter) {
if (state == kCTFontDescriptorMatchingDidFinish) {
dispatch_async(dispatch_get_main_queue(), ^{
weakTextView.font = [UIFont fontWithName:fontName size:size];
});
}
return YES;
});
}
And here's a list of all the downloadable fonts. http://iosfontlist.com