Juan
Juan

Reputation: 627

iOS custom fonts not working

I'm trying to use this font in my app. I've added it to the plist and to the project, but for some reason it is not loading on the label. I've tried to verify the font in the project with:

NSLog(@"DK Crayon Crumble: %@",
          [UIFont fontNamesForFamilyName:@"DK Crayon Crumble"]);

But I'm getting this output:

DK Crayon Crumble: ( )

Upvotes: 0

Views: 2365

Answers (4)

MaheshShanbhag
MaheshShanbhag

Reputation: 1494

Some times the fonts are visible in the project file but are not actually added to the target to do so

click on the project's name -> click on target -> Build Phases, go to

'Copy Bundle Ressources', if the concerned font(.ttf extension) file is not there add it to the list.

Clean your Project and run you should be able to see the font.

Upvotes: 0

Juan
Juan

Reputation: 627

I found the problem. For some reason Xcode it was not copying the font file to the bundle package.

Upvotes: 2

Mundi
Mundi

Reputation: 80265

The convention with the built-in fonts (you can select them in Interface Builder) is that you eliminate the spaces and add the attributes after a hyphen, such as

@"HelveticaNeue-Bold"

for Helvetica Neue, Bold.

I don't know the exact name of your font but if you follow this scheme, it should work.

Upvotes: 1

edzio27
edzio27

Reputation: 4140

Maybe the problem is that the name of font is with space. Remove spaces, in real file name, add it again to your plist and try again with code:

[UIFont fontNamesForFamilyName:@"DKCrayonCrumble"];

This link help you to set font:

set custom font

Upvotes: -1

Related Questions