Reputation: 1588
I am trying to use a custom font in my application, which is of ttf format. In the Project settings, I have addd that font name like below .
And I have added that font in my resources folder like below
And the font Which I am trying to use is this one
_enterButton.titleLabel.font = [UIFont fontWithName:@"Venus Rising" size:45.0];
If I use Arial or some other font, it works fine. But when I am trying to use this font, it is not at all working. Can anyone tell me why ??
Upvotes: 3
Views: 1918
Reputation: 3619
I downloaded the font and as I thought it has different name than what is the name of the file. Look at this image.
Also don't forget on adding the name to the Info.plist of your app, under the key "Fonts provided by application". Hope it helps! :)
Upvotes: 4
Reputation: 56
I encountered the same problem few days ago. For me the the font name was different from the ttf file name.
Try this loop to check all the font available in your app :
for (id familyName in [UIFont familyNames]) {
NSLog(@"family name : %@",familyName);
for (id font in [UIFont fontNamesForFamilyName:familyName]) {
NSLog(@" %@",font);
}
}
In your case, Venus Rising should appear as a family name but the exact name of the font you should use in your code may be VenusRisingRegular or something like that.
Upvotes: 1
Reputation: 66
You missed extension of font in info.plist, I mean in Info.plist, "Fonts provided by application" you need to set "Venus Rising.ttf" then your problem will be solved
Upvotes: 2
Reputation: 16864
UILabel *label1 = [[UILabel alloc] initWithFrame:CGRectMake(10, 30, 240, 40)];
[label1 setFont: [UIFont fontWithName: @"Grinched" size:24]];
[label1 setText:@"Grinched Font"];
[[self view] addSubview:label1];
UILabel *label2 = [[UILabel alloc] initWithFrame:CGRectMake(10, 80, 240, 40)];
[label2 setFont: [UIFont fontWithName: @"Energon" size:18]];
[label2 setText:@"Energon Font"];
[[self view] addSubview:label2];
Please try this.
It's may help to you
Upvotes: 0