2

I am trying to set a custom font on my UILabels

  • Font name: Lucida Sans Unicode.ttf
  • Font postscript: LucidaSans-Typewriter

Now I have added the font to my Plist with the name Lucida-Sans-Unicode.ttf. I've added the '-' because I read somewhere that the spaces maybe can cause the problem. I also changed the name of the font to the name with the '-' in it.

Finally on my Label I call the font like this.

[UIFont fontWithName:@"LucidaSans-Typewriter" size:12.0f]

But still the font has not been set correctly. Can someone help me ?

Kind regards

Steaphann
  • 2,797
  • 6
  • 50
  • 109
  • Ok. Here we're talking about two different families (`Lucida Sans Unicode` & `Lucida Sans Typewriter`)... so including the one in the bundle and trying to use the other wouldn't work for sure... – Alladinian Jul 02 '13 at 07:54
  • Install the ttf file on your machine and check out the name that appears on your system. The same name should be given in fontWithName: method. Hope it helps! – iCoder Jul 02 '13 at 08:02

2 Answers2

5

Here are the steps transcribed:

1) Add your custom font files into your project using Xcode as a resource
2) Add a key to your Info.plist file called Fonts provided by application.
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 Fonts provided by application array
5) Save Info.plist
Now in your application you can simply call

 [myLabel setFont:[UIFont fontWithName:@"Swis721 Lt BT" size:[lbl minimumFontSize]]]; //use font name not file name.

no need to added the '-' because it doesn't meter.

SAMIR RATHOD
  • 3,512
  • 1
  • 20
  • 45
2

First check it out that you give outlet to that UILabel correctly and then use bellow code..

UIFont *myFont = [UIFont fontWithName:@"Helvetica-BoldOblique" size:20];
[yourLable setFont:myFont];

here if you used LucidaSans font then first check that this font available in your system or not then try with bellow code..

UIFont *myFont = [UIFont fontWithName:@"LucidaSans-Typewriter" size:12.0f];
[yourLable setFont:myFont];
Stavash
  • 14,244
  • 5
  • 52
  • 80
Paras Joshi
  • 20,427
  • 11
  • 57
  • 70