Peter Kazazes
Peter Kazazes

Reputation: 3628

Issues with custom font in iOS

I followed the steps outlined in various locations using the UIAppFonts property list key. I'm using the Aller Light font. I've added it as a resource, added the font name correctly in the info property list, and am now attempting to use it, however every attempt to do so results in the default font being displayed. So far I've tried:

[leader setFont:[UIFont fontWithName:@"Aller Light" size:20.0]];
[leader setFont:[UIFont fontWithName:@"AllerLight" size:20.0]];
[leader setFont:[UIFont fontWithName:@"Aller-Light" size:20.0]];
[leader setFont:[UIFont fontWithName:@"Aller-Lt.ttf" size:20.0]];

leader.font = [UIFont fontWithName:@"Aller Light" size:20.0];
... with all the variants listed above

None of them work. Running NSLog(@"Available fonts: %@", [UIFont familyNames]); returns:

Available fonts: (
    ...
    "Aller Light",
    ...
)

Thoughts or solutions? Installing the font on my mac and looking in Font Book, the name of the font is Aller Light. Verifying the font in Font Book indicates that the font name is in fact simply Aller Light.

Upvotes: 0

Views: 627

Answers (1)

NeverBe
NeverBe

Reputation: 5038

List all fonts

for (NSString *name in [UIFont familyNames]) {
    NSLog(@"Family name : %@", name);
    for (NSString *font in [UIFont fontNamesForFamilyName:name]) {
        NSLog(@"Font name : %@", font);             
    }
}

Upvotes: 5

Related Questions