Search code examples
iosobjective-cuifontcustom-font

Can't use custom font in iOS app


I'm trying to use custom font for my iOS app. Here is what I do

I added my custom font (m.tff) to Xcode Supporting files directory. Also I create entry called Fonts provided by application with value name of the font (m.tff) in myApp.plist

In my view I have a label

UILabel *label = [[UILabel alloc]initWithFrame:CGRect(10, 20, 230, 30)];
label.font = [UIFont fontWithName:@"My custom font" size:15];

etc...

The problem is that when I launch the app the text in label is with default font instead of using the specific one.

What I miss here ?

EDITED

Well it seem works now, but the font applies only for characters like , ? but not for letters. I'm using cyrillic btw.


Solution

  • Use this to get all the fonts available

      // List all fonts on iPhone
      NSArray *familyNames = [[NSArray alloc] initWithArray:[UIFont familyNames]];
      for(NSString *familyName in familyNames)
      {
        NSLog(@"family: %@", familyName);
    
        NSArray *fontNames = [[NSArray alloc] initWithArray:[UIFont fontNamesForFamilyName:familyName]];
        for(NSString *fontName in fontNames)
        {
          NSLog(@"    font: %@", fontName);
        }
      }
    

    Look for the font you embedded and see if it is the name is the same.