Search code examples
iphoneobjective-cxcodecocoa-touchios5

Custom font is not working in my App?


In my iPhone app,

I have included two custom fonts and by referring this steps by stackoverflow questions....

How to include and use new fonts in iPhone SDK?

And Coded ....

 [lbl setFont:[UIFont fontWithName:@"glyphish.ttf" size:[lbl minimumFontSize]]];

I am building this app for Base SDK 5.0

The answer is,

[lbl setFont:[UIFont fontWithName:@"glyphish" size:[lbl minimumFontSize]]];

Thanks to all.


Solution

  • You have passed a filename (glyphish.ttf) instead of the actual font name. Most likely, the font name is Glyphish, but you need to query it somehow: either using the Mac's "Font Book.app" or via code: first, you need to query the family names via [UIFont familyNames]. Then, use [UIFont fontNamesForFamilyName:] to get the actual font names to load. For example, if your font contains a bold variant its family name would be Glyphish but font name would likely be Glyphish-Bold.