Up till now there hasn’t been an easy way to add custom fonts to your iPhone applications. As of iOS 4 it has become very easy to do. Here is what you need to do in order to add custom fonts:
- Add your custom font files into your project using XCode as a resource
- 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:@"CustomFontName" size:12] to get the custom font to use with your UILabels and UITextViews, etc…
It’s that simple!

Comments
Great !!\\r\\nThis works perfectly.\\r\\n\\r\\nGot any clue how to use a custom font in interface builder for iOS4?
hi, this already works in 3.2 but please is there any chance that I load some font file from my app documents folder and use it to build a UIFont object?
have any idea to use custom font in below 3.2 version in all componenent
Seconding P5yCH0\\’s question – how can you use this with Interface Builder??
Thanks for this. Was exactly what I needed to find. Simple, straightforward and to the point!\\r\\n\\r\\nThank you.
Worked great. Thanks.\\r\\n\\r\\nDave
It \\”sort of\\” work for me. Text is displayed, but with a default font instead of my font. (Named \\”Petrucci\\”). If I call for a random font name, ex \\”PetrucciTest\\” nothing is displayed, so at least the system knows of Petrucci, but won\\’t display it.\\r\\n\\r\\nDid anyone have this problem?
Apparently people are getting this to work. I can get it to work in the simulator but not the device.
[...] was following the instructions on this website but I didn’t manage to get the custom fonts working. After trying for a while I found out the [...]
I haven\\’t tried this but if you install the font to your system, you can select it in Interface builder as a font for your label. If that doesn\\’t work, after you create your interface in Interface Builder, you can manually set the font in code in the viewDidLoad method of your controller.
I can\\’t get this to work in Xcode 3.2.5, IOS4.2
Hi,\\r\\n Great walk-through, awesome.\\r\\nThanx alot
Great these step will work as good.But this is work dynamical way.so how to change statical way?. I mean these steps works only when a label crate code.but not work in the interface builder (.XIB). while track the label and set font in the label attribute property section. if any one help to solve these problem.\\r\\n\\r\\n\\r\\nthanks in advance\\r\\n\\r\\nSenthilkumar
[...] font, which to my surprise was in OTF format. The app appears to have used it without a problem. This page describes the very simple procedure of font 'installation' for your [...]
[...] 3rd party fonts please I downloaded a *.ttf file from the web, and I followed the example here BeefyApps Blog : Custom Fonts in iOS 4, except in Step 4 I added a "Fonts provided by application" array in the *plist file. I [...]
hooray for short and efficient howto\\’s! Thanks
I am not getting it, I am doing everything you mentioned but the font doesn\\’t come
Can someone please help me with this, I can\\’t get it work??
^Farah, did you get your app running?\\r\\nI\\’m following the steps and still can\\’t get my font to work. Tried multiple fonts.
Got it working, for those that dont have it working, if your font has two words in its name, ie \\”Century Gothic\\”(bold),\\r\\n \\r\\nyour code should look like this\\r\\n[UIFont fontWithName:@\\"CenturyGothic-Bold\\" size:14];
How to edit info.plist in order to add key to it?
Not getting it..:(\\r\\ntried all the things as mentioned
great snippet, thanks a lot!\\r\\n\\r\\nfor people who still have trouble with this:\\r\\nBe sure not to use the fonts filename but it\\’s \\”real name\\”. It is displayed in the Window-Header when you open the font with Font Book.
[...] http://blog.beefyapps.com/2010/06/custom-fonts-in-ios-4/ LD_AddCustomAttr("AdOpt", "1"); LD_AddCustomAttr("Origin", "other"); [...]
[...] http://blog.beefyapps.com/2010/06/custom-fonts-in-ios-4/ [...]
Thanks a bunch!!!\\r\\nI was missing the \\”add the array of fonts to the .plist\\” part!!!
Works great – thanks! I really wish that Apple simplifies adding new components like this to the info.plist file. Now, you have to know the name of the setting, which could be simplified with a simple ui.
I downloaded a font family that came in .ttf format. I followed the same steps and it did not work.\\r\\n\\r\\nTurns out that you don\\’t have to mention the extension when using [UIFont fontWithName:@\\"CustomFontName\\" size:12]\\r\\n\\r\\nBasically in the above line of code don\\’t use CustomFont.ttf
[...] Custom font to UITableViewCell http://blog.beefyapps.com/2010/06/custom-fonts-in-ios-4/ [...]
Post a Comment