Reputation: 110452
I am having trouble adding this custom font:
[totalRecordedText setFont:[UIFont fontWithName:@"LiberationMono-Bold" size:19]];
I have added a file to my project called "LiberationMono-Bold.ttf". How do I now link the font file to the reference? Right now, it is not displaying the font (it just uses a system default).
Note that this does work by contrast:
[totalRecordedText setFont:[UIFont fontWithName:@"ProximaNova-Bold" size:19]];
Upvotes: 0
Views: 1856
Reputation: 1557
The .ttf
file name may or may not be the same as the actual font name. This is what I do to find the real name of the font
I want to use
for (NSString *font in [UIFont familyNames]) {
NSLog(@"%@", [UIFont fontNamesForFamilyName:font]);
}
This will print out all the fonts that are supported by your system in a dictionary
fashion, the Font-family name being the key. Find the key of your desired font and you will see all the sub-fonts in that key. Use that name in the command
[totalRecordedText setFont:[UIFont fontWithName:<actual_font_name> size:19]];
and you should be good. !!
~ Happy Coding
Upvotes: 2
Reputation: 35
Use this example
UIFont *font = [UIFont fontWithName:@"MyFont" size:20];
[label setFont:font];
Where "MyFont" would be a TrueType or OpenType file in your project (sans the file extension), and label would be an instance of UILabel.
Upvotes: 0