Magnus
Magnus

Reputation: 1442

Adding font in iPhone application

I'm trying to add a custom font to my iPhone app.

The font's name is: Susa-Regular.otf

I downloaded the font, installed it, dragged it over to xCode. Then I went into info.plist and added a row called "Fonts provided by application" and typed in Susa-Regular.otf

 UILabel *myLabel = [[UILabel alloc]initWithFrame:frame];
 [myLabel setFont:[UIFont fontWithName:@"Susa-Regular" size: 35]];

When I run the app, the font is still the same. I don't get any error messages either.

Any idea why it doesn't work?

Upvotes: 0

Views: 698

Answers (3)

Jarson
Jarson

Reputation: 121

I use the uifont-name-grabber posted at: http://forgecode.net/2010/08/uifont-name-grabber/

Just drop the fonts you want into the xcode project, add the file name to its plist, and run it on the device you are building for, it will email you a complete font list using the names that UIFont fontWithName: expects.

Upvotes: 0

David K. Hess
David K. Hess

Reputation: 17246

More than likely the "font name" is not the same as the file name.

Open the font in Font Book and see how it represents the font name and use that instead with spaces removed.

You can also use [UIFont familyNames] and [UIFont fontNamesForFamilyName:] to discover what name iOS is using for it.

Upvotes: 2

Magnus
Magnus

Reputation: 1442

I figured it out. I dropped the dash and it worked perfectly!

 [myLabel setFont:[UIFont fontWithName:@"SusaRegular" size: 35]];

Upvotes: 1

Related Questions