I'm having trouble loading a custom font.
.m file:
- (void)viewDidLoad
{
[label setFont:[UIFont fontWithName:@"BIO.TTF" size:32]];
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
I did type in the font name "BIO.TTF" in the .plist file. The font is provided by the application.
Use file name in plist, and font name in your code.
The accepted answer is incorrect.
Custom font names under iOS do not always correspond to what finder reports. Custom fonts use the post script name for identification.
Say my font's name is "Museo Sans Rounded" and I want the 300 weight. These are really a family but you can think of them as individual fonts.
Open up Font Book, click on the info tab on the top left, and look at the PostScript name. This is the name you will use when you actually code. In the example photo, you can see the postscript name as "MuseoSansRounded-300".
Then Code
UIFont *myFont = [UIFont fontWithName:@"MuseoSansRounded-300" andSize:20];
label.font = [UIFont fontWithName:@"MuseoSans-500" size:24.0];
You have to edit also you plist file, ale look out for system font name, my off file has name MuseoSans500.otf but system name is MuseoSans 500 - in font name, space is "-" symbol, so you have to use fontWithName MuseoSans-500. Check your system font name of BIO.
May be the file name "BIO.TTF" that you are using is not the correct name of file.
Open this .ttf file in the font book and use the name that is being shown in font book, as that name is the correct name which should be used in the code to load the fonts.
The name of font which you install in your mac is different than you are using.so check the name in your font application and copy that name.
This is only happen when you forgot to add into your plist or your font name is different than
installed font name.
Try selecting "i" button from the Font Book App and use the PostScript name of the font
Other thing can be that if you drop your fonts files to project, they actualy not there as resources so you cant use them. You need to select "Target Membership".
Select font in xcode and on right side you have bunch of options and informations, there is "Target Membership" select your project.