How to use custom font in iOS ( Eg: Helvetica CY.ttf ) with Xcode programatically

Deepak Chandra picture Deepak Chandra · Oct 31, 2014 · Viewed 25.6k times · Source
  • I am trying to use Helvetica CY font in my app. I have configured it as recommended by apple docs.
  • The custom font shows up in dropdown in Storyboard, but unable to use the same font programatically in my class file.
  • I have logged all font families available for the app, but "Helvetica CY" is not printed on console log.

Any help will be appreciated.

Thanks!

Answer

Rajesh Loganathan picture Rajesh Loganathan · Oct 31, 2014

Its simple only. Its working for me in xcode6.1 too.

Try using this steps :

Step 1: Include your fonts in your XCode project

Step 2: Make sure that they’re included in the target

Step 3: Double check that your fonts are included as Resources in your bundle

Step 4: Include your iOS custom fonts in your application plist

Step 5: Find the name of the font

for (NSString* family in [UIFont familyNames])
{
    NSLog(@"%@", family);

    for (NSString* name in [UIFont fontNamesForFamilyName: family])
    {
        NSLog(@"  %@", name);
    }
}

Step 6: Use UIFont and specify the name of the font

label.font = [UIFont fontWithName:@"Helvetica CY" size:20];