Can not include .ttf font into project

2019-02-07 03:06发布

问题:

I am trying to include the font "Hipchick" into my project but it does not work. I have tested a few methods and ended up with this one: iOS tips: Custom Fonts to try to solve this but it still doesn't work.

Here is some screens and code:

The font is added to the project: "hitch__.ttf"

It is added to the .plist.

It is in the bundle.

Here is the info about the font.

- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.

NSLog(@"hipch___: %@",[UIFont fontNamesForFamilyName:@"Hipchick"]);



testLbl.font = [UIFont fontWithName:@"Hipchick" size:30];
testLbl.text = @"Frank Zappa";
}

I have tried "Hipchick", "hipchick" and "hitch__" but it still display the wrong font.

I would really appreciate any help possible.

回答1:

This is Step for, How to add custom font in Application.

1 - Add .TTF font in your application
2 - Modify the application-info.plist file.
3 - Add the key "Fonts provided by application" to a new row
4 - and add each .TTF file (of font) to each line.

For more info read This and This site.

FOR MOREINFORMATION :

But after adding font to your application, you need to apply/write real name of your font, so check How do I get the font name from an otf or ttf file?