0

I've looked through almost every thread on creating a custom font for a Label. What am i doing wrong?

plist:

enter image description here

bundle resources:

enter image description here

resources:

enter image description here

The code:

UILabel *headLine = [[UILabel alloc] initWithFrame:CGRectMake(screenWidth/2-55, screenHeight/2-100, 110, 35)];
headLine.textColor = headlineColor;
headLine.text = @"HEADLINE";
UIFont *pacificoFont = [UIFont fontWithName:@"Pacifico" size:35.0f];
headLine.textAlignment = UITextAlignmentCenter;
[headLine setFont:pacificoFont];
[self.view addSubview: headLine];
Rajneesh071
  • 30,846
  • 15
  • 61
  • 74
user3423384
  • 667
  • 2
  • 8
  • 18
  • possible duplicate of [How to use custom fonts in iPhone SDK?](http://stackoverflow.com/questions/14376941/how-to-use-custom-fonts-in-iphone-sdk) – Rajneesh071 Apr 02 '14 at 11:11

2 Answers2

0

There are a lot of errors that can be done with custom fonts (more info here).

However, I suspect that your family name is wrong. Use this to print the available family names and check if "Pacifico" is there:

for (NSString* family in [UIFont familyNames]) {
    NSLog(@"%@", family);

    for (NSString* name in [UIFont fontNamesForFamilyName: family]) {
        NSLog(@"  %@", name);
    }
 }

When you declare a UIFont with a custom name you have to specify the family of the font, and not the filename of the ttf file :)

Tiago Almeida
  • 14,081
  • 3
  • 67
  • 82
0

follow the below steps:

1)Add your custom font files into your project using Xcode as a resource

2)Add a key to your Info.plist file called UIAppFonts.

3)Make this key an array

4)For each font you have, enter the full name of your font file (including the extension) as items to the UIAppFonts array

5)Save Info.plist

6)Now in your application you can simply call [UIFont fontWithName:@"CustomFontName" size:12] to get the custom font to use with your UILabels and UITextViews, etc…

note: Make sure the fonts are in your Copy Bundle Resources.