xcode custom ttf font not working xcode custom ttf font not working ios ios

xcode custom ttf font not working


I would suspect that you haven't added the font file to your target, so that it's not copied to the app's resources. Your code works fine here and the font does show up as "Press Start K" in the list of font families.


Another possibility is that you might be calling the wrong font name when you try to call your font. Use:

Swift 2.1+

//Check which fonts availablefor family: String in UIFont.familyNames(){   print("\(family)")   for names: String in UIFont.fontNamesForFamilyName(family)   {       print("== \(names)")   }}

Objective C

//Check which fonts availablefor (NSString* family in [UIFont familyNames]){    NSLog(@"FONT %@", family);    for (NSString* name in [UIFont fontNamesForFamilyName: family])    {        NSLog(@"  %@", name);    }}

To find the actual names of the fonts you should be using with UIFont(name: "yourFontName", size: 24.0) (swift) or [UIFont fontWithName:@"yourFontName" size:16.0f] (obj c). The custom font names you add to your plist must match whatever the files are called in your directory (including the .ttf or .otf), but the code referencing the fonts must match the font names you get from this output. Good luck fontmasters!