0

I am import the font in my app folder. Then i added font in info.plist file. Like..... Fonts provided by application--->add two font.

Then set the font to title.After create the UILabel to set the font. Like this

 self.title = @"Home";
CGRect frame = CGRectMake(0, 0,100, 44);
label = [[UILabel alloc] initWithFrame:frame];
label.backgroundColor = [UIColor clearColor];
label.font = [UIFont fontWithName:@"Benguiat Gothic" size:9];
label.textAlignment = UITextAlignmentCenter;
self.navigationItem.titleView = label;
label.text =self.title;

This code written in viewdidload method.

But the font is not changed.its appear only default font for that label.

rmaddy
  • 314,917
  • 42
  • 532
  • 579
HariKrishnan.P
  • 1,204
  • 13
  • 23

3 Answers3

5

1 Add your custom font into your project , i.e. Dragged the font file(CALIBRIZ_0.TTF) into XCode project.

2 Edit Info.plist: Add a new entry with the key "Fonts provided by application".

3 For each of your files, add the file name to this arrayenter image description here

4.Opened the font in font book(double click on your font in finder) to see what the real filename is and I see this:

enter image description here

Now set font to your label

yourLabel.font = [UIFont fontWithName:@"Calibri" size:15];
Rohit
  • 577
  • 1
  • 3
  • 13
0

First download your relevant font

Add your custom font into your project , i.e. Dragged the font file(Berlin Sans FB.TTF) into XCode project.

Add a new entry with the key "Fonts provided by application".

enter image description here

Now use this font in your textview

txtview.font = [UIFont fontWithName:@"Berlin Sans FB" size:15];

i used Berlin Sans FB you use your teleugu font

for more detail check this link

Gajendra Rawat
  • 3,673
  • 2
  • 19
  • 36
0

Using a custom font in iOS requires a few steps:

  1. Have access to the TTF or OTF file for the desired font.
  2. Drag the TTF or OTF font file into your Xcode project.
  3. Located the application's Plist file and add a new row with the key "Fonts provided by the application.
  4. Make sure that the associated value in the Plist perfectly matches the naming of the dragged in font file.
  5. In your code, you can now assign the custom font to be used with your label, textfield or any other control that has the font property.

    [myLabel setFont:[UIFont fontWithName:@"Benguiat Gothic" size:12.0f]];

Or, if you prefer dot notation syntax

myLabel.font = [UIFont fontWithName:@"Benguiat Gothic" size: 12.0f];

There's a few things to take into consideration. The actual naming of the Font File may not always be what you have to pass in as a string literal. Some custom fonts may have different weights associated with it (Light, Regular, Medium, Bold, Italic Bold etc). If the font isn't displaying as you would expect and all steps above have been explicitly followed then it could be down to the string you're using in your code.

You can get the list of font family names in debug by logging out as so:

NSLog (@"Font families: %@", [UIFont familyNames]);

That should give you a decent indication of what to actually use in your code when defining the custom font for use with the label.

Paul Morris
  • 1,763
  • 10
  • 33
  • 47