SlateEntropy
SlateEntropy

Reputation: 4018

Working out custom font name

I'm having trouble getting a font to display. (Quicksand)

<key>UIAppFonts</key>
<array>
    <string>bebas.ttf</string>
    <string>Quicksand_Bold.ttf</string>
    <string>Quicksand_Book.ttf</string>
</array>

I have tried various ways to call it "Quicksand", "Quicksand Bold", "Quicksand-Bold" and so on..

UILabel *theLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, 20, 890, 60)];
theLabel.font = [UIFont fontWithName:@"Quicksand-Bold" size:50];
theLabel.text = @"Label Text";

Is there an easy way to find the name I should use? In Font Book it is naming it "Quicksand Bold Regular", which also does not work.

Upvotes: 0

Views: 714

Answers (2)

SlateEntropy
SlateEntropy

Reputation: 4018

A little late to respond, but I have solved it.

I had simply forgotten to add the files to the Bundle Resources list.

Copy Bundle Resources

Upvotes: 0

MJN
MJN

Reputation: 10818

Sometimes the name of the font file and the name of the font in the system are different. You should print the names of all fonts with NSLog and see what name the system uses.

NSFontManager* fm =[NSFontManager sharedFontManager]
NSLog(@"%@", [fm availableFonts]);

I wrote this up in a tutorial on my blog about adding fonts to applications: How to add fonts to iOS and OSX applications.

Upvotes: 4

Related Questions