Customize the font in bold

I have successfully added a custom font to my project, and it works fine by executing this line of code, among other things:

[sideScoreLabel setFont:[UIFont fontWithName:@"Caveman" size:34]]; 

However, I want this custom font to be bold. I researched this, and everyone seems to be saying to add "-Bold" to the end of the font name or "-BoldMT" so it looks like this:

  [sideScoreLabel setFont:[UIFont fontWithName:@"Caveman-Bold" size:34]]; 

When I run the project, it does not seem to work. Does anyone know what I'm doing wrong? Maybe the font I'm using doesn't work with Bolding?

Thanks!

+4
source share
3 answers

I have successfully added a custom font to my project, and it works fine by executing this line of code, among other things:

Dude, you added CUSTOM FONT to your iOS kit.

If you need a bold version of this font, you need to provide one that the system will not do for you.

+8
source

You are on the right track when you mention that a font cannot be shown in bold. You can verify this with this bit of code that will show the console of all available fonts, and then you can search for your font there.

 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]);   }   [fontNames release]; } [familyNames release]; 
+7
source
  • Find Spotlight Font Book
  • Open it and find the font in the font list
  • As you can see, any font has several names. In your code, you should always use the PostScript name of your font. Sometimes the PostScript name is not like the file name of your font.
+4
source

All Articles