24

Possible Duplicate:
Can I embed a custom font in an iPhone application?

How can I customize font in my iPhone app? Is it possible? How can I use this custom font in a UILabel?

I am trying to add MYRIADPRO-SEMIBOLD.OTF font in my App.

and the code is

UIFont *customFont = [UIFont fontWithName:@"MYRIADPRO-SEMIBOLD" size:35]; 
titleLbl.font = customFont; 

And the Plist is

enter image description here

Nilanshu Jaiswal
  • 1,583
  • 3
  • 23
  • 34
Dev
  • 3,885
  • 10
  • 39
  • 65

3 Answers3

67

Try the steps below:

1. Make configuration in the info.plist as shown in Image

enter image description here

2. Now you should use that added file

UIFont *customFont = [UIFont fontWithName:@"fontName" size:size];

// further you may set That Font to any Label etc.

EDIT: Make Sure you have added that file in your resources Bundle.

enter image description here

Yogurt
  • 2,913
  • 2
  • 32
  • 63
Kamar Shad
  • 6,089
  • 1
  • 29
  • 56
  • @Dev you should pass the Name of That File from which you want to use Font.and see my edit.Make Sure you have added that file in your resources Bundle. – Kamar Shad Oct 23 '12 at 12:02
  • 2
    @Dev This is the solution, it works. Be sure you added the font file to the resources folder. And when you set the font in the source code use : (for instance if you want to use bolda.ttf) [UIFont fontWithName@"bolda" size:15]; (do not add .ttf) – Ashbay Oct 23 '12 at 12:07
  • No ashbay, this is not working for me.Iam adding like UIFont *customFont = [UIFont fontWithName:@"MYRIADPRO-SEMIBOLD" size:35]; titleLbl.font = customFont; – Dev Oct 23 '12 at 12:19
  • @Dev have you added `Custom file` in your resource bundle? – Kamar Shad Oct 23 '12 at 12:20
  • Yeah I added file to the resource folder – Dev Oct 23 '12 at 12:25
  • @Dev it can not be possible. just check again under the `Target ->buildPhase-->Copy bundle Resource` find whether the file is available or not.if not just drag and drop into that place.see my edit – Kamar Shad Oct 23 '12 at 12:30
  • Kamarshad, The file is available there.. – Dev Oct 23 '12 at 12:32
  • @dev can you put your code which you were using ? – Kamar Shad Oct 23 '12 at 12:33
  • Yeah..sure.. I have edited the question. please check – Dev Oct 23 '12 at 12:38
  • Yeah... Now it working... Once more downloaded a new font file and place it in the resource folder... Thank you so much... :) – Dev Oct 23 '12 at 12:48
  • 2
    The important bit is that the name referenced in `fontWithName:size:` may not be the same as file name. On a Mac, if you open the font with Font Book (default app), it will show the correct name in the title bar. You can rename the file but the *font name* will not change. – SaltyNuts Apr 08 '15 at 18:37
5
  1. Copy your font file into Resources.

  2. In your application .plist create (if it exists just create a row) a row called Fonts provided by application and then in item 0 copy your font name for example Ciutadella-Bold.otf

  3. Then you can define this font in your application:

    UIFont *CiutadellaBold = [UIFont fontWithName:@"Ciutadella-Bold" size:17.0f];
    
  4. And use it in for instance in UILabel:

    [uiLabel setFont:CiutadellaBold];
    
Nilanshu Jaiswal
  • 1,583
  • 3
  • 23
  • 34
edzio27
  • 4,126
  • 7
  • 33
  • 48
1

It is totally possible. Please check the following links to implement your solution.

iPhone Development: how to use custom fonts?

How to add custom fonts to an iPhone app?

how to use custom font in iphone application

Can I embed a custom font in an iPhone application?

I hope these links help.

Yogurt
  • 2,913
  • 2
  • 32
  • 63
IronManGill
  • 7,222
  • 2
  • 31
  • 52