By Airsource Ltd

2008-12-11 20:21:11 8 Comments

I would like to have an app include a custom font for rendering text, load it, and then use it with standard UIKit elements like UILabel. Is this possible?


@Dima Deplov 2014-09-02 08:08:45

With iOS 8+ and Xcode 6+ you can make this easily. Here are the steps:

1) Drag and drop your font to Xcode Supporting Files folder. Don't forget to mark your app at Add to targets section. From this moment you can use this font in IB and choose it from font pallet.

enter image description here

2) To make this font available to in your device, open your info.plist and add Fonts provided by application key. It will contain Item 0 key, you must add your font name as the value. Font name can vary from your font file name. But first, try to add your filename in most cases this work.

enter image description here

If not, this article always helped me.

Here is swift snippet of the code from this article to help you find your font name.

func allFonts(){

   for family in UIFont.familyNames(){


       for name in UIFont.fontNamesForFamilyName(family.description)
           println("  \(name)")




I want to mention, that you need to add font files to your Target's Build Phases, Copy Bundle Resources. Without it, you won't see your font on the device. And it could lead to unexpected behaviour.

For example, I encounter a bug, when UITextField have custom font, but this font wasn't in the Copy Bundle Resources. And when I segue to the viewcontroller with this textfield, there is a delay about 4 seconds before viewDidLoad function was called. Resolving font troubles removed this delay. So, recommend to check it twice. (rdar://20028250) Btw, I wasn't able to reproduce the bug, but I'm sure that problem was with the font.

@jbnunn 2015-01-15 02:51:31

Thank you, works great for Swift in XCode 6

@Rivera 2015-04-16 14:29:41

Just a note. Custom fonts are not available in LaunchScreens even if properly configured in IB. Which may be logic.

@Dima Deplov 2015-04-17 18:48:51

@Rivera wow, great note! Didn't know that. Possible alternative is to use UIImage with text instead, I think.

@spongessuck 2016-01-04 19:29:15

@Rivera, thanks for that info- is it documented anywhere? I was going over the steps repeatedly thinking I missed a step.

@Dima Deplov 2016-01-05 10:53:45

@spongessuck not sure about your question, but there is some docs‌​ts/…

@user2691469 2013-12-11 09:11:38

yes you can use custom font in your application

step by step following there:

  • Add your custom font files into your project in supporting files
  • Add a key to your Info.plist file called UIAppFonts.
  • Make this key an array
  • For each font you have, enter the full name of your font file (including the extension) as items to the UIAppFonts array
  • Save Info.plist Now in your application you can simply call [UIFont fontWithName:@"your Custom font Name" size:20] to get the custom font to use with your UILabels

after applying this if your not getting correct font then you double click on the custom font , and see carefully top side font name is comming and copy this font , paste, here [UIFont fontWithName:@" here past your Custom font Name" size:20] i hope you will get correct answer

@commanda 2009-04-30 21:57:27

Edit: As of iOS 3.2, this functionality is built in. If you need to support pre-3.2, you can still use this solution.

I created a simple module that extends UILabel and handles loading .ttf files. I released it opensource under the Apache license and put it on github Here.

The important files are FontLabel.h and FontLabel.m.

It uses some of the code from Genericrich's answer.

Browse the source Here.


  • Copy your font file into resources

  • Add a key to your Info.plist file called UIAppFonts. ("Fonts provided by application)

  • Make this key an array

  • For each font you have, enter the full name of your font file (including the extension) as items to the UIAppFonts array

  • Save Info.plist

  • Now in your application you can simply call [UIFont fontWithName:@"CustomFontName" size:15] to get the custom font to use with your UILabels and UITextViews, etc…

For More Information

@4thSpace 2009-06-14 19:06:31

I've tried using your code but it crashes quite often depending on the font. For example, try using the African or Tiki fonts from here

@teepusink 2009-11-15 09:09:45

This library works great. I need help with the vertical spacing though. Can't figure out how to do it. So I have this message.numberOfLines = 3; How do I control the vertical spacing between line 1, and line 2 and line 3? Thank you, Tee

@Raj Pawan Gumdal 2010-04-14 12:24:10

If this method is followed, we have to implement the drawing logic. What if we want to display the font directly on a UILabel instance instead of a custom sub-class of UILabel?

@Parth Bhatt 2013-01-28 06:36:23

@commanda Hello commanda, the link you provided in your answer seems to be unavailable.

@commanda 2013-01-28 22:52:21

@ParthBhatt You should use the solution provided in instead of FontLabel, since this functionality is now provided by CocoaTouch.

@Lily Ballard 2013-05-10 21:40:49

@ParthBhatt: I don't know why the repo is no longer hosted at zynga, but it's available at

@Kirtikumar A. 2013-03-09 04:34:15

follow this step

1)Copy your font in your project

2)open your .plist file in source code mode...(Note- Dont open info.plist)

3)Before that - Right click on your font and open it in fontforge or similar editor and install it in your system ,It should be install

4)Type this


5)Type this code in your class .m

 [lblPoints setFont:[UIFont fontWithName:@"Myriad Pro" size:15.0]];

Here lblPoints will be change as of your UILabel

Done!! If still your font not work,check your fonts compatibility first

@Kirtikumar A. 2013-03-12 06:24:51

Why downvote as my ans is correct and fully tested on iOS device

@Raptor 2013-08-12 07:58:52

why don't open info.plist ?

@DrMickeyLauer 2017-10-11 15:35:35

As all the previous answers indicated, it's very well possible, and pretty easy in newer iOS versions.

I know this is not a technical answer, but since a lot of people do make it wrong (thus effectively violating licenses which may cost you a lot of money if you're being sued), let me strengthen one caveat here: Embedding a custom font in an iOS (or any other kind) app is basically redistributing the font. Most licenses for commercial fonts do forbid redistribution, so please make sure you're acting according to the license.

@SKris 2012-03-27 19:45:33

If you are using xcode 4.3, you have to add the font to the Build Phase under Copy Bundle Resources, according to in the thread, Custom Fonts Xcode 4.3. This worked for me, here are the steps I took for custom fonts to work in my app:

  1. Add the font to your project. I dragged and dropped the OTF (or TTF) files to a new group I created and accepted xcode's choice of copying the files over to the project folder.
  2. Create the UIAppFonts array with your fonts listed as items within the array. Just the names, not the extension (e.g. "GothamBold", "GothamBold-Italic").
  3. Click on the project name way at the top of the Project Navigator on the left side of the screen.
  4. Click on the Build Phases tab that appears in the main area of xcode.
  5. Expand the "Copy Bundle Resources" section and click on "+" to add the font.
  6. Select the font file from the file navigator that pops open when you click on the "+".
  7. Do this for every font you have to add to the project.

@cnotethegr8 2012-12-23 12:10:41

Thank you! Searched everywhere for a different answer. Copy to bundle resources did the trick for me.

@Daniel Krom 2015-10-29 10:53:54

Swift, code way: (works also with swift 2.0)

Add the required fonts to your project (just like adding images, just drag to Xcode), make sure that they are targeted to your project
add this method and load custom fonts (recommended in appDelegate didFinishLaunchingWithOptions)

func loadFont(filePath: String) {

    let fontData = NSData(contentsOfFile: filePath)!

    let dataProvider = CGDataProviderCreateWithCFData(fontData)
    let cgFont = CGFontCreateWithDataProvider(dataProvider)!

    var error: Unmanaged<CFError>?
    if !CTFontManagerRegisterGraphicsFont(cgFont, &error) {
        let errorDescription: CFStringRef = CFErrorCopyDescription(error!.takeUnretainedValue())
        print("Unable to load font: %@", errorDescription, terminator: "")


Use example:

if let fontPath = NSBundle.mainBundle().pathForResource("My-Font", ofType: "ttf"){

Use the font:

UIFont(name: "My-Font", size: 16.5)

@Stephen Jesse 2016-08-04 14:55:08

Just wondering, how come you won't just add the font in your Info.plist seems like a lot more work for essentially the same thing.

@ColossalChris 2015-09-29 16:53:57

I would recommend following one of my favorite short tutorials here: from which this information comes.

Step 1 - Drag your .ttf or .otf from Finder into your Project

NOTE - Make sure to click the box to 'Add to targets' on your main application target

Drag font files into your project and click to add them to your target

If you forgot to click to add it to your target then click on the font file in your project hierarchy and on the right side panel click the main app target in the Target Membership section

how to add fonts to app target if you forgot

To make sure your fonts are part of your app target make sure they show up in your Copy Bundle Resources in Build Phases

how to check resources to see if fonts are part of app target

Step 2 - Add the font file names to your Plist

Go to the Custom iOS Target Properties in your Info Section and add a key to the items in that section called Fonts provided by application (you should see it come up as an option as you type it and it will set itself up as an array. Click the little arrow to open up the array items and type in the names of the .ttf or .otf files that you added to let your app know that these are the font files you want available

NOTE - If your app crashes right after this step then check your spelling on the items you add here

example plist with custom fonts added

Step 3 - Find out the names of your fonts so you can call them

Quite often the font name seen by your application is different from what you think it is based on the filename for that font, put this in your code and look over the log your application makes to see what font name to call in your code


for family: String in UIFont.familyNames(){
  for names: String in UIFont.fontNamesForFamilyName(family){
      print("== \(names)")

Objective C

for (NSString* family in [UIFont familyNames]){
    NSLog(@"%@", family);
    for (NSString* name in [UIFont fontNamesForFamilyName: family]){
        NSLog(@"  %@", name);

Your log should look something like this:

Example of searching log to find font names

Step 4 - Use your new custom font using the name from Step 3


 label.font = UIFont(name: "SourceSansPro-Regular", size: 18)

Objective C

 label.font = [UIFont fontWithName:@"SourceSansPro-Regular" size:18];

@Unome 2015-11-18 22:10:06

Fantastic work, I appreciate your thorough, simple, and well written post +1

@Akhil Bhadauria 2014-03-26 07:00:11

yes you can use custom font in your application

step by step following there:

Add your custom font files into your project in supporting files

Add a key to your Info.plist file called UIAppFonts.

Make this key an array

For each font you have, enter the full name of your font file (including the extension) as items to the UIAppFonts array

Save Info.plist Now in your application you can simply call [UIFont fontWithName:@"your Custom font Name" size:20] to get the custom font to use with your UILabels after applying this if your not getting correct font then you double click on the custom font , and see carefully top side font name is comming and copy this font , paste, here [UIFont fontWithName:@" here past your Custom font Name" size:20]

i hope you will get correct answer

@samvermette 2010-04-11 05:01:05

iOS 3.2 and later support this. Straight from the What's New in iPhone OS 3.2 doc:

Custom Font Support
Applications that want to use custom fonts can now include those fonts in their application bundle and register those fonts with the system by including the UIAppFonts key in their Info.plist file. The value of this key is an array of strings identifying the font files in the application’s bundle. When the system sees the key, it loads the specified fonts and makes them available to the application.

Once the fonts have been set in the Info.plist, you can use your custom fonts as any other font in IB or programatically.

There is an ongoing thread on Apple Developer Forums: (login required)

And here's an excellent and simple 3 steps tutorial on how to achieve this (broken link removed)

  1. Add your custom font files into your project using Xcode as a resource
  2. Add a key to your Info.plist file called UIAppFonts.
  3. Make this key an array
  4. For each font you have, enter the full name of your font file (including the extension) as items to the UIAppFonts array
  5. Save Info.plist
  6. Now in your application you can simply call [UIFont fontWithName:@"CustomFontName" size:12] to get the custom font to use with your UILabels and UITextViews, etc…

Also: Make sure the fonts are in your Copy Bundle Resources.

@samvermette 2010-04-15 07:36:29

FontLabel (1st answer) is what I use for older OS.

@pm_labs 2010-09-20 13:34:20

Here's a step by step tutorial for iOS4:

@Elise van Looij 2010-11-29 13:45:02

I'm not sure why you think this works only for the iPad. The documentation that you quote above has one more line: "This key is supported in iOS 3.2 and later." I've just implemented it in my iPhone app and it works fine.

@samvermette 2010-11-30 02:51:51

I posted this answer back when 3.2 was live and not iOS 4. My answer had a note at the end that says that this obviously worked with iOS 4. Edited it again so it's more obvious, thanks.

@Pacu 2011-01-13 23:38:48

The tutorial works like a charm

@Willster 2011-01-28 18:14:10

This tutorial is very good. Importantly, the NSString argument to [UIFont fontWithName:...] is the OS name for the font rather than the file name.

@Daniel Wood 2012-03-20 16:51:06

Before anyone else spends 3 hours installing fontforge in order to find the actual postscript name of the font required by iOS. I'll point out that you can simply press Cmd+I on the font in font book to find this information.

@Steve Potter 2012-03-29 20:05:21

After struggling to get the right font name, I just listed out the installed fonts and found it. Very helpful. Here's the code: for ( NSString *familyName in [UIFont familyNames] ) { NSLog(@"Family %@", familyName); NSLog(@"Names = %@", [UIFont fontNamesForFamilyName:familyName]); }

@Van Du Tran 2012-04-02 21:18:38

Hi Steve, your code does not list the custom fonts. I have trouble getting my custom font to work, even with Daniel's trick.

@Mc- 2012-06-04 15:16:25

Key Point > Make sure the fonts are in your Copy Bundle Resources Tip: I used Illustator to an image with the font, saved as SVG and opened to TExtEditor to see the real name of the font. Looking for an easier way... :)

@NSTJ 2012-08-01 04:03:11

The CustomFontName to use in the above procedure is the PostScript name field found in the font's information in Font Book on OS X.

@railwayparade 2012-12-06 23:35:25

When I dragged the font into XCode it was automatically included in my target. Clicked the "Target Membership" checkbox

@Mickey 2012-12-20 09:55:07

If your code is not working, make sure you found font file appear in "Build Phases" -> "Copy Bundle Resouces"

@rock_walker 2015-04-24 14:48:43

.otf is working. Note: if your font file sits deeply in resources folder, f.e. : Resources/Test.bundle/Fonts/font.ttf , then specify this path in info.plist as Test.bundle/Fonts/font.ttf

@Raptor 2013-08-12 08:57:20

As an enhancement @bdev's answer, here is an updated version for listing out custom fonts only.

Step 1: Find out all system fonts using @bdev's answer & save to file.

Put the following code in first View Controller's -(void)viewDidLoad, after [super viewDidLoad] (or in App Delegate):

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,
                                                     NSUserDomainMask, YES);
NSMutableArray *system_fonts = [NSMutableArray array];
for (NSString *familyName in [UIFont familyNames]) {
    for (NSString *fontName in [UIFont fontNamesForFamilyName:familyName]) {
        [system_fonts addObject:fontName];
if([paths count] > 0) {
    [system_fonts writeToFile:[[paths objectAtIndex:0]
                               stringByAppendingPathComponent:@"array.out"] atomically:YES];

Run the App once. Stop it afterwards.

Step 2: Add custom font to project

Using the method shown in the accepted answer, add your custom fonts ( remember to update the .plist and add the font files to build by checking Add To Target.

Step 3: Compare the system fonts with current font list

Replace the codes in Step 1 to:

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,
                                                     NSUserDomainMask, YES);
NSMutableArray *system_fonts = [NSMutableArray arrayWithContentsOfFile:[[paths objectAtIndex:0]

for (NSString *familyName in [UIFont familyNames]) {
    for (NSString *fontName in [UIFont fontNamesForFamilyName:familyName]) {
        if (![system_fonts containsObject:fontName]) {
            NSLog(@"%@", fontName);

Run the App and the list of custom fonts you added will be shown.

This applies to iOS 3.2 till iOS 6 ( future releases are probably working fine ). Works with .ttc and .ttf as well.

@Nishan29 2012-10-23 06:53:33

You can add the required "FONT" files within the resources folder. Then go to the Project Info.plist file and use the KEY "Fonts provided by the application" and value as "FONT NAME".

Then you can call the method [UIFont fontwithName:@"FONT NAME" size:12];

@Subrat 2012-03-30 10:12:55

It is very easy to add a new font on your existing iOS App.

You just need to add the font e.g. font.ttf into your Resource Folder.

Open your application info.plist. Add a new row as "Fonts provided by application" and type the font name as font.ttf.

And when setting the font do as setFont:"corresponding Font Name"

You can check whether your font is added or not by NSArray *check = [UIFont familyNames];.

It returns all the font your application support.

@RichX 2011-03-16 09:24:23

Better solution is to add a new property "Fonts provided by application" to your info.plist file.

Then, you can use your custom font like normal UIFont.

@Jacob Wallström 2009-10-28 14:22:02

I have been trying out the various suggestions on this page on iOS 3.1.2 and these are my conclusions:

Simply using [UIFont fontWithName:size:] with the fonts in the Resources directory will not work, even if the FOND name is set using FontForge.

[UIFont fontWithName:size:] will work if the fonts are loaded first using GSFontAddFromFile. But GSFontAddFromFile is not part of iOS 3.1.2 so it has to be dynamically loaded as described by @rpetrich.

@David M. 2013-03-19 23:39:34

There is a new way to use custom fonts, starting with iOS 4.1. It allows you to load fonts dynamically, be they from files included with the app, downloaded data, or what have you. It also lets you load fonts as you need them, whereas the old method loads them all at app startup time, which can take too long if you have many fonts.

The new method is described at ios-dynamic-font-loading

You use the CTFontManagerRegisterGraphicsFont function, giving it a buffer with your font data. It's then available to UIFont and web views, just as with the old method. Here's the sample code from that link:

NSData *inData = /* your font-file data */;
CFErrorRef error;
CGDataProviderRef provider = CGDataProviderCreateWithCFData((CFDataRef)inData);
CGFontRef font = CGFontCreateWithDataProvider(provider);
if (! CTFontManagerRegisterGraphicsFont(font, &error)) {
    CFStringRef errorDescription = CFErrorCopyDescription(error)
    NSLog(@"Failed to load font: %@", errorDescription);

@Hiren 2013-04-10 12:38:56

I have used this code but get the &error Failed to load font: The operation couldn’t be completed. ( error 105 - Could not register the CGFont '<CGFont (0x14fe7df0): Shruti>')

@David M. 2013-04-21 20:05:27

According to the documentation, error 105 is kCTFontManagerErrorAlreadyRegistered, "The file has already been registered in the specified scope."‌​nce/…

@Bharat Gulati 2013-05-10 21:29:10

Although some of the answers above are correct, I have written a detailed visual tutorial for people still having problems with fonts.

The solutions above which tell you to add the font to the plist and use

[self.labelOutlet setFont:[UIFont fontWithName:@"Sathu" size:10]];

are the correct ones. Please do now use any other hackish way. If you are still facing problems with finding font names and adding them, here is the tutorial -

Using custom fonts in ios application

@ari gold 2013-06-09 02:07:07

I just tried this. Seems to work but my font is tiny, no matter what size I set it. For what it's worth, I'm using a freely available OTF file:

@Bharat Gulati 2013-06-26 18:54:26

Try it with any other custom font and if problem persists, let me know. If it works that way, then there is a problem with your font.

@ari gold 2013-06-26 19:54:21

Thanks.. turns out I had to use the PostScript name.

@Jarson 2011-12-29 19:20:31

For iOS 3.2 and above: Use the methods provided by several above, which are:

  1. Add your font file (for example, Chalkduster.ttf) to Resources folder of the project in XCode.
  2. Open info.plist and add a new key called UIAppFonts. The type of this key should be array.
  3. Add your custom font name to this array including extension ("Chalkduster.ttf").
  4. Use [UIFont fontWithName:@"Real Font Name" size:16] in your application.

BUT The "Real Font Name" is not always the one you see in Fontbook. The best way is to ask your device which fonts it sees and what the exact names are.

I use the uifont-name-grabber posted at: uifont-name-grabber

Just drop the fonts you want into the xcode project, add the file name to its plist, and run it on the device you are building for, it will email you a complete font list using the names that UIFont fontWithName: expects.

@alexey 2010-07-07 21:05:57

There is a simple way to use custom fonts in iOS 4.

  1. Add your font file (for example, Chalkduster.ttf) to Resources folder of the project in XCode.
  2. Open info.plist and add a new key called UIAppFonts. The type of this key should be array.
  3. Add your custom font name to this array including extension (Chalkduster.ttf).
  4. Now you can use [UIFont fontWithName:@"Chalkduster" size:16] in your application.

Unfortunately, IB doesn't allow to initialize labels with custom fonts. See this question to solve this problem. My favorite solution is to use custom UILabel subclass:

@implementation CustomFontLabel

- (id)initWithCoder:(NSCoder *)decoder
    if (self = [super initWithCoder: decoder])
        [self setFont: [UIFont fontWithName: @"Chalkduster" size: self.font.pointSize]];
    return self;


@Jesse Rusak 2010-10-19 22:25:43

This seems to be supported back to 3.2, not just 4.0+

@Joe D'Andrea 2011-08-01 14:58:57

Thanks! The problem I've been having is that custom fonts seem to skew a bit high (extra space below) vs their built-in counterparts. I've tried using the FontLabel repo from GitHub, which helps some of the time, but not all of the time.

@slayton 2011-08-22 03:57:21

Its worth noting that the string you pass to the UIFont constructor is NOT the filename minus the extension its the font's internal name. I had problems loading a font with a filename that I had shortened. When I used the entire font name as contained IN the file the font loaded fine.

@electromaggot 2011-11-20 08:16:39

What slayton just said is critical. [UIFont fontWithName: expects the "Full name" of the font, which is visible by opening it up in Font Book and selecting: Preview --> Show Font Info

@ElizaS 2013-01-28 15:34:35

I made everything possible but the new fonts dont appear so I found the solution:

When you drag the fot files(otf or ttf) DONT forget to check the checkbox under "Add to targets".

After doing that your font will appear and everything will work fine.

@bdev 2012-10-17 13:29:50

In Info.plist add the entry "Fonts provided by application" and include the font names as strings:

Fonts provided by application
           Item 0        myfontname.ttf
           Item 1        myfontname-bold.ttf

Then check to make sure your font is included by running :

for (NSString *familyName in [UIFont familyNames]) {
    for (NSString *fontName in [UIFont fontNamesForFamilyName:familyName]) {
         NSLog(@"%@", fontName);

Note that your ttf file name might not be the same name that you use when you set the font for your label (you can use the code above to get the "fontWithName" parameter):

[label setFont:[UIFont fontWithName:@"MyFontName-Regular" size:18]];

@Hemang 2012-11-19 09:30:55

Helped me to get the actual name of the font with different parameters....

@PetrV 2013-01-16 15:36:32

wonderful snippet to debug font names :-) !

@Alejandro Luengo 2012-09-26 09:58:53

First add the font in .odt format to your resources, in this case we will use DINEngschriftStd.otf, then use this code to assign the font to the label

[theUILabel setFont:[UIFont fontWithName:@"DINEngschriftStd" size:21]];

To make sure your font is loaded on the project just call

NSLog(@"Available Font Families: %@", [UIFont familyNames]);

On the .plist you must declare the font. Just add a 'Fonts provided by application' record and add a item 0 string with the name of the font (DINEngschriftStd.otf)

@AaronBaker 2012-09-03 16:13:27

I've combined some of the advice on this page into something that works for me on iOS 5.

First, you have to add the custom font to your project. Then, you need to follow the advice of @iPhoneDev and add the font to your info.plist file.

After you do that, this works:

UIFont *yourCustomFont = [UIFont fontWithName:@"YOUR-CUSTOM-FONT-POSTSCRIPT-NAME" size:14.0];
[yourUILabel setFont:yourCustomFont];

However, you need to know the Postscript name of your font. Just follow @Daniel Wood's advice and press command-i while you're in FontBook.

Then, enjoy your custom font.

@5566 2011-03-22 05:59:09

Here's the step by step instructions how to do it. No need extra library or any special coding.

Most of the time the issue is with the font not the method. The best way to do it is to use a font that for sure will work, like verdana or geogia. Then change to the intended font. If it does not work, maybe the font name is not right, or the font is not a well formated font.

@Praveenkumar 2012-11-28 09:21:58

+1 Helpful one..

@rpetrich 2009-04-30 23:25:43

edit: This answer is defunct as of iOS3.2; use UIAppFonts

The only way I've been able to successfully load custom UIFonts is via the private GraphicsServices framework.

The following will load all the .ttf fonts in the application's main bundle:

BOOL GSFontAddFromFile(const char * path);
NSUInteger loadFonts()
    NSUInteger newFontCount = 0;
    for (NSString *fontFile in [[NSBundle mainBundle] pathsForResourcesOfType:@"ttf" inDirectory:nil])
        newFontCount += GSFontAddFromFile([fontFile UTF8String]);
    return newFontCount;

Once fonts are loaded, they can be used just like the Apple-provided fonts:

NSLog(@"Available Font Families: %@", [UIFont familyNames]);
[label setFont:[UIFont fontWithName:@"Consolas" size:20.0f]];

GraphicsServices can even be loaded at runtime in case the API disappears in the future:

#import <dlfcn.h>
NSUInteger loadFonts()
    NSUInteger newFontCount = 0;
    NSBundle *frameworkBundle = [NSBundle bundleWithIdentifier:@""];
    const char *frameworkPath = [[frameworkBundle executablePath] UTF8String];
    if (frameworkPath) {
        void *graphicsServices = dlopen(frameworkPath, RTLD_NOLOAD | RTLD_LAZY);
        if (graphicsServices) {
            BOOL (*GSFontAddFromFile)(const char *) = dlsym(graphicsServices, "GSFontAddFromFile");
            if (GSFontAddFromFile)
                for (NSString *fontFile in [[NSBundle mainBundle] pathsForResourcesOfType:@"ttf" inDirectory:nil])
                    newFontCount += GSFontAddFromFile([fontFile UTF8String]);
    return newFontCount;

@pixel 2009-07-14 17:31:05

note to those wondering, this does work, but you'll need to call loadFonts right before using the font -- they don't seem to stay loaded throughout the application

@M. Ryan 2009-11-12 19:30:20

In OS 3.0 you definitely need to use the second second example, don't forget the import. Worked pretty well for me.

@pixel 2009-12-01 22:05:17

Another note -- this is a private framework, and dynamically loads it... both of which will likely stop the acceptance of your app into the AppStore.

@rpetrich 2009-12-02 02:05:43

Yup, the answer clearly states it's private.

@Raj Pawan Gumdal 2010-04-14 12:36:14

What is the conclusion? What alternatives to this method?

@rpetrich 2010-04-15 02:30:27

It's very VERY private. If you can deal with drawing the text yourself, you can use CGFontCreateWithDataProvider. UIAppFonts can be used on 3.2+

@Luke Mcneice 2011-01-17 08:44:16

This method works for otf fonts too.

@Luke Mcneice 2011-01-17 09:01:22

SHould also note that [NSString sizeWithFont:[UIFont fontWithName:@"customFont" size:14]]; returns 0 width and height for any custom fonts I have tried.

@Eric Brotto 2011-11-12 19:45:24

+1 for logging all the font names. I had loaded my ttf file correctly, but was using the wrong font name in [UIFont fontWithName:@"fake name" size:22.0f]].

@Eugene 2012-01-18 11:45:14

+1 and eternal love for availableFontFamilies

@user576862 2011-01-15 16:40:06

One important notice: You should use the "PostScript name" associated with the font, not its Full name or Family name. This name can often be different from the normal name of the font.

@Nano 2010-12-07 01:16:18

Find the TTF in finder and "Get Info". Under the heading "Full name:" it gave me a name which I then used with fontWithName (I just copied and pasted the exact name, in this case no '.ttf' extension was necessary).

@Sat 2013-01-24 09:33:35

Thanks . It worked for me .

@ByteNirvana 2009-05-01 01:04:44

Maybe the author forgot to give the font a Mac FOND name?

  1. Open the font in FontForge then go to Element>Font Info
  2. There is a "Mac" Option where you can set the FOND name.
  3. Under File>Export Font you can create a new ttf

You could also give the "Apple" option in the export dialog a try.

DISCLAIMER: I'm not a IPhone developer!

@John 2009-04-27 22:56:36

It's not out yet, but the next version of cocos2d (2d game framework) will support variable length bitmap fonts as character maps.

The author doesn't have a nailed down release date for this version, but I did see a posting that indicated it would be in the next month or two.

@Matt Sephton 2009-04-09 11:59:46

Look up ATSApplicationFontsPath

A simple plist entry that allows you to include the font file(s) in your app resources folder and they "just work" in your app.

@Airsource Ltd 2009-04-09 13:53:59

Have you tried this on device? I had no joy, and googling suggests that this plist entry isn't supported on iPhone, even though it's documented for iPhone OS.

@Matt Sephton 2009-04-09 15:48:42

Sorry, I am only using it in an OS X app at the moment.

Related Questions

Sponsored Content

38 Answered Questions

[SOLVED] How can I disable the UITableView selection?

23 Answered Questions

[SOLVED] How to link to apps on the app store

92 Answered Questions

40 Answered Questions

[SOLVED] How can I develop for iPhone using a Windows development machine?

  • 2008-08-22 13:35:01
  • ryan
  • 1096600 View
  • 1151 Score
  • 40 Answer
  • Tags:   ios iphone windows

18 Answered Questions

[SOLVED] How to Set a Custom Font in the ActionBar Title?

16 Answered Questions

[SOLVED] Set a default font for whole iOS app?

  • 2012-01-03 01:44:57
  • Sam Jarman
  • 93824 View
  • 146 Score
  • 16 Answer
  • Tags:   ios fonts

26 Answered Questions

[SOLVED] How do I sort an NSMutableArray with custom objects in it?

21 Answered Questions

[SOLVED] How to add some non-standard font to a website?

3 Answered Questions

[SOLVED] Can I embed a custom font in an Android application?

  • 2010-08-06 13:24:49
  • Pentium10
  • 50539 View
  • 77 Score
  • 3 Answer
  • Tags:   android fonts

3 Answered Questions

[SOLVED] How do I associate file types with an iPhone application?

  • 2010-05-05 14:59:22
  • Mihai Damian
  • 121780 View
  • 317 Score
  • 3 Answer
  • Tags:   ios cocoa-touch

Sponsored Content