Embedding Fonts in an Application
Sunday, July 5, 2009 at 7:19PM I'm working on an application that needs to display the current timecode of a movie file. I wanted to create a display that looked something like an old-school VCR clock and found a font whose license allowed me to distribute it freely. The next problem was being able include the font in my application's bundle rather than having to have it installed in one of the traditional font folders. Fortunately this turned out to be easier than I expected.
There is a key you can add to your Info.plist file called 'Application Fonts Resource Path' or ATSApplicationFontsPath. This simply specifies the folder within the application bundle's Resources folder where any additional fonts you want to use are stored. Once this is done you can use the usual NSFont methods such as fontWithName:size: to use the fonts.
Below is a step-by-step guide to doing this:
1. Add a font to your project's resources.
2. Add a new Copy Files Build Phase to the Target project. Ensure the destination is Resources and specify a path.

In this case the font will be stored in the bundle's Resources/AppFonts folder.
3. Add the ATSApplicationFontsPath key to the Info.plist file. This can either be done via Xcode or the Property List editor or via a text editor.


4. Drag the font from the Resources group to the new build phase. You may need to delete the font from the 'Copy Bundle Resources' build phase.

5. After building your project the font file should be stored in the designated font folder.

Download
Download a sample project.
Crystal Font
The font used in this example is Crystal by Allen R Walden.
Please Note
This approach works under 10.5 but I am not sure if it works with earlier versions of OS X.
fonts in
In-Depth Articles
Reader Comments (1)
You have a talent for making it so clear.Your post is a great source of knowledge.Helped is appreciated.