Gros Gros - 1 year ago 68
iOS Question

Can I embed a custom font in a bundle and access it from an ios framework?

I'm creating an ios framework with its bundle for packaging ressources (nib, images, fonts) and I'm trying to embed a custom font in the bundle but I'm not able to load it from the framework, is it possible ?

1) I can localize the font file with this:

NSString *fontPath = [[NSBundle frameworkBundle] pathForResource:@"MyCustomFont" ofType:@"ttf"];

2) But I can't get it in my fonts lists:
NSArray * array = [UIFont familyNames];

I included my font name in the bundle's plist with a "Fonts provided by application", without success, tried also in the app info plist, include it in the framework ressource without success.

I can load the nib and images from the bundle (by prefixing with the bundle's name) but not for the font. Any thought ?

EDIT : I saw the following post : Can I embed a custom font in an iPhone application?, but the question is just "Can I embed a custom font in an iPhone application?" not "Can I embed a custom font in an external framework/bundle ?" It also makes references to a dynamic loading which is interesting but it is using private api, which is not usable solution for a framework.


Answer Source

This is a new method that lets you load fonts dynamically without putting them in your Info.plist:

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download