By Lolloz89


2012-02-24 14:29:21 8 Comments

I'm trying to use this font in my project but it won't work. I added the .ttf file in my project and added its name in the MyApp-Info.plist under the key: Fonts provided by application. Then I tried this:

 [_titleLabel setFont:[UIFont fontWithName:@"chalkboard" size:_titleLabel.font.pointSize]];

I also checked if the name of the font is really "chalkboard" and it is. The displayed font is still Helvetica, only smaller. Where could the problem be? Thanks in advance.

6 comments

@user3432072 2014-03-18 07:50:00

Not All Font's you imported are working. Just try to test into another font. If it works then it is not recognized by Xcode. Just remember that it must be in your project plist file and it has to be a extension name like ".otf" or ".ttf" in plist. And also add it in "Copy Bundle Resources" under target

@Azam 2013-09-13 08:02:54

  1. Include your fonts in your XCode project
  2. Make sure that they’re included in the Target Membership in File Inspector tab
  3. Include you font in Project Name > Build Phase > Copy Bundle Resources
  4. Include your iOS custom fonts in your application plist. Add a new row called “Fonts provided by application” and put your font name and extension as parameter.
  5. Find the name of the font.
  6. Use UIFont and specify the name of the font.

    UILabel *headingLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 290, 300, 30)];
    headingLabel.text = @"WELCOME";
    headingLabel.font = [UIFont fontWithName:@"Arvo" size:14.0];

Source: http://codewithchris.com/common-mistakes-with-adding-custom-fonts-to-your-ios-app/

@Shmidt 2012-02-24 17:51:38

You need to use font name, not filename. Font name is inside the ttf file.

You can find font names for iOS here: http://iosfonts.com/

This code will list all your font names in your app, put it somewhere in viewDidLoad on main controller, run app and then in console found the right name for the font.

NSArray *familyNames = [[NSArray alloc] initWithArray:[UIFont familyNames]];

NSArray *fontNames;
NSInteger indFamily, indFont;
for (indFamily=0; indFamily<[familyNames count]; ++indFamily)
{
    NSLog(@"Family name: %@", [familyNames objectAtIndex:indFamily]);
    fontNames = [[NSArray alloc] initWithArray:
                 [UIFont fontNamesForFamilyName:
                  [familyNames objectAtIndex:indFamily]]];
    for (indFont=0; indFont<[fontNames count]; ++indFont)
    {
        NSLog(@"    Font name: %@", [fontNames objectAtIndex:indFont]);
    }
}

Upd.

You can also right click on font file in Finder, get Info and copy full name. But it is not always 100%.

@Lolloz89 2012-02-24 20:42:43

As I said, I actually used the font name, the one I read when I opened the font and it didn't work. Unfortunately (try opening the link) the chalkboard font I would use is not the same one installed on iOs..

@Shmidt 2012-02-25 07:13:07

Have you tried [_titleLabel setFont:[UIFont fontWithName:@"Chalkboard-Regular" size:_titleLabel.font.pointSize]];

@Lolloz89 2012-02-25 09:18:59

Didn't work too..

@Shmidt 2012-02-25 11:23:16

Try to find out family name with this code(I updated my answer)

@Tim Sullivan 2012-02-25 22:18:25

@Flink: Have you tried your font-listing code in Xcode 4.3 with a custom font installed? Because it hasn't worked for me.

@Shmidt 2012-02-26 09:06:49

Yes, I tried and it works. OK, it seems that when you added the font to the project you didn't check "add to target", so font isn't used now. Choose "target-build phases-copy bundle resources" and add your font.

@Lolloz89 2012-02-26 11:57:17

I'm sorry, I tried everything you said but still didn't work...

@Shmidt 2012-02-26 13:13:03

Last thing — check that font filename is written with extension(.ttf) in app-info.plist. After that paste here console output.

@Rob Bonner 2012-03-27 12:13:27

Anyone find a answer to this issue? I am on 4.3.2 and can confirm that the custom fonts are coming up in the above font listing code, but are not showing up in the list in the identity browser.

@Héctor Ramos 2012-03-31 01:15:41

Same problem here.

@hajn 2013-04-02 11:50:30

Just wanted to add for future reference: I couldn't find the problem why my font, with the fontname in OS X fontbook being "Function-Caps-Regular", would not load in my iOS App until I used this script, where it was named "FunctionCapsRegular", without the "-". Once changed, the font could be loaded.. I can't understand this inconsistency..

@JScarry 2013-06-11 21:35:07

Works for me on Xcode 4.6. As noted int the post just above this by hajn, be careful when you call the font. The font file name is not the same as the font name. That's why this method is so useful. For example, I added "Bradley Hand ITC TT-Bold" font file to my project as described in the OP, but the font name is actually, BradleyHandITCTT-Bold.

@FreeAppl3 2013-04-21 13:43:02

Its my experience that not "all" fonts are compatible. Most work, but you will run into a few fonts that just for some reason will not be recognized through code no matter how hard you try... Just a heads up for anyone having issues, just try another font!

@JScarry 2013-06-19 01:08:16

I thought I'd run into one when I tried to add Bitstream Vera Sans Mono. It turns out that the steps above work great for adding the font to the app. I displays fine in a UITableView but it doesn't seem to work as a font choice for drawInRect.

@Arne 2012-03-26 11:00:49

Flinks answer is a handy tool to check if your fonts are loaded properly.

Do the following:

[_titleLabel setFont:[UIFont fontWithName:@"chalkboard" size:_titleLabel.font.pointSize]];

Make sure your fonts are included in your bundle:

  • Click your project
  • Go to build phases
  • Under 'Copy Bundle Resources', make sure your fonts are included

Worked for me :)

@Leachy Peachy 2012-04-01 00:43:46

Thanks for this answer ame. This was the "missing step" that I was looking for. ;-)

@Kiran Panesar 2012-04-09 15:44:22

I've been searching for an answer to this for ages! It was the "Copy Bundle Resources" that was getting me! Thanks so much!

@Arne 2012-04-12 14:32:27

Happy I could help :)

@Steve Simitzis 2012-04-25 03:50:07

I never needed the "Copy Bundle Resources" step until 4.3.2, so I'm glad to have found this after five hours of pulling my hair out.

@Alex Milde 2012-05-23 10:33:53

thanks for the copy bundle resources. i owe you a huge pint of german beer ;)

@Arne 2012-06-04 11:10:31

Will keep you to that, thanks ;) But seriously, glad I could help :)

@Arda Dogantemur 2012-03-20 08:14:51

Xcode 4.3.1 Custom Font have problem. Because when i create new project and try to add custom fonts in Xcode 4.2.1 there is no problem.

I did several times. Interesting...

Related Questions

Sponsored Content

14 Answered Questions

[SOLVED] Custom Font in ios not working

6 Answered Questions

[SOLVED] How to use custom fonts in a mac application?

2 Answered Questions

[SOLVED] Custom font not showing on device, but does on simulator

1 Answered Questions

[SOLVED] Cannot use a custom font in IOS Application

2 Answered Questions

[SOLVED] custom font with UILabel in navigation bar

1 Answered Questions

[SOLVED] Set custom font for unicode characters in iPhone

2 Answered Questions

[SOLVED] Unable To Add Custom Fonts To iOS 4.3

  • 2012-08-11 11:27:59
  • NightFury
  • 673 View
  • 0 Score
  • 2 Answer
  • Tags:   ios4 custom-font

2 Answered Questions

[SOLVED] Custom Font Does Not Work

4 Answered Questions

[SOLVED] Add Custom Fonts In Xcode 4.1

1 Answered Questions

How to set custom font size in iphone

Sponsored Content