2

I am trying to add a specific font in my app. I did all the work like adding the font to resources, to plist and to Copy Bundle Resources. I even added font classes as well and also googled a lot. But all in vain, nothing worked for me.

Cilan
  • 13,101
  • 3
  • 34
  • 51
Deepak Khiwani
  • 734
  • 1
  • 8
  • 33

4 Answers4

9

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: https://devforums.apple.com/thread/37824 (login required)

And here's an excellent tutorial on how to achieve this.

Here are the steps transcribed:

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…

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

Copied from : Can I embed a custom font in an iPhone application?

Community
  • 1
  • 1
Anoop Vaidya
  • 46,283
  • 15
  • 111
  • 140
0

Happy New Year to you too. I had this problem. My problem was that the name of the font in the p.list was written with capital letters. When I wrote the name in the .plist the same as in the file name, it was fixed.

Luda
  • 7,282
  • 12
  • 79
  • 139
  • Thanks for your support,as you said that you have problem regarding capital and small letters. But in my case the font is different when I drag it from finder and its name is different in font book, which name should I use. – Deepak Khiwani Jan 01 '13 at 09:34
  • You should make sure they are the same everywhere. I would have use the font book name – Luda Jan 01 '13 at 09:40
  • Look I have font with this name in finder ***ufonts.com_bernhardgothicsg-medium.ttf*** and ***BernhardGothicSG*** in font book which name should I use – Deepak Khiwani Jan 01 '13 at 09:44
  • I think BernhardGothicSG.ttf. I had fontName.ttf file and fontName.TTF in plist I changes to fontName.ttf in plist and all worked well. You should try to play with it. – Luda Jan 01 '13 at 09:58
0

Check the Font Label, That will help you, Screen Shot of Font Label is attached

enter image description here

junaidsidhu
  • 3,539
  • 1
  • 27
  • 49
0

Check the name of the font you have added into the plist are same as the name of the font files. Then write the following code nslog (@"%@", [uifont familynames]); Check the name of the font you have added from the list in nslog and apply that hope it will work for you. Check my spelling mistakes and cases for the class names or method names.

Exploring
  • 925
  • 6
  • 18