5

I want to add a non-system font to my iPhone/iPad app.

I have added the font file to the project and also added the font to the UIAppFonts property of the info.plist.

To load the font I'm using fontWithName of UIFont. But the name of the font does not seem to be the file name, with or without extension, nor the name that appears in Font Book.

UIFont* font = [UIFont fontWithName:@"What goes here?" size:10];

Where do I find out the name of the font?

hpique
  • 119,096
  • 131
  • 338
  • 476
  • You can see here for the detail answer http://stackoverflow.com/questions/360751/can-i-embed-a-custom-font-in-an-iphone-application?rq=1 – Pratibha Gupta Apr 10 '15 at 05:16

2 Answers2

5

UIFont's +familyNames and then +fontNamesForFamilyName: should do the trick.

Josh Bleecher Snyder
  • 8,262
  • 3
  • 35
  • 37
  • Thanks Josh! It certainly should, but I can't believe that there's no easier way to find out. – hpique Nov 10 '10 at 14:27
  • Great thanks - is there any way of finding out the fontNames wihtout having to run the app? – jowie Jun 21 '12 at 14:19
  • 1
    @jowie I think there's an app or two in the app store that list fonts (Lorem Ipsum on the iPad, IIRC, don't recall about iPhone). Other than that, there's no other way that I'm aware of... – Josh Bleecher Snyder Jun 21 '12 at 17:29
2

If you open the ttf file in Font Book on your Mac, the title of the window is the name iOS uses too. (In my case, AvantGarde Bk BT)

enter image description here

Souleiman
  • 3,360
  • 4
  • 23
  • 21