0

I'm trying to set a custom font and, following the last answer to this question, I seem to have the font working in the project.

The only trick is that it's always the same size - too small. I'm trying to set it rather large but it's always small, no matter the size. Here's the line of code I'm using, as per the instructions in the above link.

    self.timeLabel.font = [UIFont fontWithName:@"DistProTh" size:48];

I know the line works because I can change the font name (DistProTh) to something another font (say, Didot) and everything's fine. It therefore seems to me to be an issue with the font (which is freely available) but the font works ok in other applications (Stickies for example). Sadly, I'm no font expert..

Community
  • 1
  • 1
ari gold
  • 2,074
  • 3
  • 25
  • 51

2 Answers2

1

The fontName parameter of the fontWithName: method is the full name of the font, not its file name. DistProTh is the file name; the full name of that font is District Pro Thin.

This should fix the problem:

self.timeLabel.font = [UIFont fontWithName:@"District Pro Thin" size:48];

Font name and file name are often the same, but that's not always the case. To look up the name of the font, locate your font in the Font Book application, and press Command+I to view font's information.

Sergey Kalinichenko
  • 714,442
  • 84
  • 1,110
  • 1,523
  • Hmm. Didn't do the trick. I wonder if there's a way for fonts to know that they're going to be on a mobile device and stop working. I say that because I was trying another 'free' font and saw this page - note the categories & prices: http://www.myfonts.com/fonts/font-fabric/code-pro/buy.html – ari gold Jun 10 '13 at 00:06
  • I got another free font working. One called "CODE Light". I wonder if there isn't an issue with "District Pro Thin". – ari gold Jun 10 '13 at 00:19
  • @arigold I was about to mention the postscript name, which has been mentioned in [this highly upvoted comment](http://stackoverflow.com/questions/360751/can-i-embed-a-custom-font-in-an-iphone-application#comment12465682_2616101) to one of the answers to the question that you linked. – Sergey Kalinichenko Jun 10 '13 at 00:53
0

Turns out it needed what Font Book calls the "PostScript name" which, in the case of District Pro Thin is DistrictPro-Thin.

Incidentally, either the "PostScript name" or the "full name" (as per Font Book) worked for the font called "Code Light" but not for "District Pro Thin".

ari gold
  • 2,074
  • 3
  • 25
  • 51