3

please tell me how to add new font to iphone xcode3.2.

royhowie
  • 11,075
  • 14
  • 50
  • 67
priyanka
  • 2,076
  • 1
  • 16
  • 20

4 Answers4

8

This functionality isn't built into UILabel/UIFont in iOS < 3.2. But there is a third-party solution you can use: FontLabel

In iOS 3.2+, there's the UIAppFonts plist key!

Just do this before using it: add your font file (such as myfont.ttf) to your project, then edit the Info.plist like so:

info.plist

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
jtbandes
  • 115,675
  • 35
  • 233
  • 266
  • but i want to use UIAppFonts you have any idea how to use way – priyanka Jul 28 '10 at 06:03
  • 1
    i use this approach but when i load font using below code UIFont *myF = [UIFont fontWithName:@"my font name" size:12]; myF is return null; – priyanka Jul 28 '10 at 09:31
  • I would think that the name is wrong or the file isn't getting included in the project. There's a good post about this here: http://www.perfectline.co.uk/blog/uiappfonts-custom-fonts-with-the-iphoneipad-3-2-sdk – bjtitus Jul 28 '10 at 13:31
  • Hello! For me it doesn't work it crashes with an EXC_BAD_ACCESS when i want to retrieve the fontfamilynames. I already posted a questions [here](http://stackoverflow.com/questions/8727710/adding-a-uifont-and-looking-for-the-fontfamily-crashes-with-exc-bad-access). Could you tell me, what i'm doing wrong? Thx – NicTesla Jan 04 '12 at 13:32
2

The above methods worked for me in xcode 3.2! Thanks!:

step 1: drag your font into your project (prob a good idea to not have spaces in the font name) step 2: add a row to your info.plist file like shown above to enter your font. step 3: in, viewDidLoad() or wherever you are setting your label, enter code:

 UIFont *myFont = [UIFont fontWithName:@"secondbreakfast" size:40];
 myLabel.font = myFont;
jjmad
  • 21
  • 1
0

I did it with the following way:

  1. Add the font type to the Xcode : Under the XIB, go the font setting -> manage font

  2. Add the font to the label:

    UIFont *myFont = [UIFont fontWithName:@"myfont" size:12]; label.font = myFont;

Hope it help

DNA App Lab
  • 51
  • 1
  • 2
0

But in xcode 5

  1. Go to xcode preferences -> Fonts and colors.
  2. Then click on T button in the textField of Font.

A list of all colors open then click on setting button in bottom left corner and go to manage fonts

Here select All fonts and then add your own ttf file by clicking on plus button and your Font will be added.

mmmmmm
  • 32,227
  • 27
  • 88
  • 117