Add Custom Fonts In Xcode 4.1

22,917

Solution 1

The font name isn't the name of the file. What you want to do is double click on the font in Finder.

This should open it in Font Book like this image

The font name you want is the one in the title which I've highlighted so attractively in red.

Solution 2

I just spent a big chunk of my day trying to figure my problem out... what I missed was, when I dragged the .ttf file into xcode, I did not select my app's name under "Add to target:" section.

Even though it seemed as if the file was in the correct directory and what not, it wasn't recognising it under the family names, using this code:

NSLog(@"FONT FAMILIES\n%@",[UIFont familyNames]);

So hopefully this can help someone if they're stuck.

Solution 3

The above advice did not work for me, so I wanted to share what did:

Opening the font in Finder gave a long name that did not work (TypeWrong Smudged - DGL), but when I looked for the same font in the Photoshop font list it showed the name as just TypeWrong, which did work. So if Finder shows a long name with spaces in it, you might want to try just using the first space-free chunk.

Solution 4

You have to check what is the font name it is at times different from font file name...

check this link

Share:
22,917
or azran
Author by

or azran

Updated on April 26, 2020

Comments

  • or azran
    or azran about 4 years

    i want to use custom fonts in y application.

    i have declared the "Fonts provided by the application" in the info.Plist file

    and set the label.font to the font with name with / without the .TTF extension

    draged the TTF file in to the project and copied the file to the project

    created an outlet to the label but still, nothing works.

    if someone knows what is going on over there i would like to get some help.

    recently i have noticed the this problem are known @ the 4.1 (xcode version).

    TNX :)

  • BBog
    BBog over 12 years
    Thanks! Your answer helped me too
  • bendytree
    bendytree almost 12 years
    What about variants like Light, Regular, & Bold? The highlighted title does not change for these.
  • Andre Cytryn
    Andre Cytryn almost 12 years
    @bendytree did you find how to dod that?
  • bendytree
    bendytree almost 12 years
    I was able to add -Light or -Bold to the end & it worked. Not sure if this works across the board.
  • Raheel Sadiq
    Raheel Sadiq over 11 years
    thanks i just found your post and found the name of the font in the file, and it worked, many thanks although its not my post :D
  • Robbie
    Robbie over 11 years
    Great stuff!!! I looked all over the place and this is the first answer that I found that helped me with my issue. Thanks for pointing this out
  • iPhone Guy
    iPhone Guy over 10 years
    we also have to trim empty spaces.