3

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 .

enter image description here

And I have added that font in my resources folder like below

enter image description here

And the font Which I am trying to use is this one enter image description here

_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 ??

4 Answers 4

4

I downloaded the font and as I thought it has different name than what is the name of the file. Look at this image.

enter image description here

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! :)

2
  • If the Font style is having only Regular , can't we make it as a Bold ?? I am trying to add a title to button. And the font which I am using is mentioned above. It has only regular type
    – Perseus
    Jul 17, 2012 at 9:37
  • That is not possible. If the font doesn't have a bold version, you can't make it bold using just the regular one. Jul 17, 2012 at 9:38
2

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

1
  • I have tried many times previously with and without the extension. And after seeing your reply I wondered how it is going to solve and I thought to give it a last try. YES , it worked. Thanks a lot man!!
    – Perseus
    Jul 17, 2012 at 9:25
1

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.

1
  • This is helpful, however I think it's easier to just right click the font and Get info - you can find the actual name there. :) Jul 17, 2012 at 9:29
0
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

3
  • The link which you have given looks cool. I have solved before this . But anyway thank you so much, it is a nice blog, I read tat topic
    – Perseus
    Jul 17, 2012 at 9:27
  • This doesn't solve his problem, he doesn't want to use "Grinched" nor "Energon" font. His problem is the actual name of the font. Jul 17, 2012 at 9:28
  • But issue for the font does not work here is tutorial for the how to instal external font into our project. Jul 17, 2012 at 9:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.