Search code examples
iosxcodefontstruetype

Having trouble installing specific font in an iOS app - incompatible TTF?


There are some font files in my code repo for the font Nubian and Nubian-Alt. They are licensed and paid for and they need to be used. However I cannot use this font in iOS, and I cannot open the font with Font Book even though the font previews OK in Finder and is identified as a Truetype Font.

Finder's view of the "bad" font

I started by trying to add Nubian-Medium to the iOS app - using the key "Fonts provided by application" in the app's Info.plist. The font did not appear in the list generated using:

 for (NSString *familyName in [UIFont familyNames]) {
   for (NSString *fontName in [UIFont fontNamesForFamilyName:familyName]) {
     NSLog(@"%@", fontName);
   }
 }

I checked the Target's "Copy Bundle Resources" Build Phase, saw the font had been added to the list.

I tried adding another font I have used in another app, "chess-merida-unicode.ttf", to check I was adding a font correctly - I copied it to the app and added it to the array of fonts provided by application, saw it appear in the "Copy Bundle Resources" list, it was reported as available using the above code snippet.

Next I took a look at the font in OS X - double-clicking does open Font Book but the font is not opened or added. When I tried to drag all the Nubian fonts into Font Book as a new collection it reported problems with all the files, specifically in tables contained within the font file.

Font Problems displayed by Font Book

Selecting all fonts and then choosing proceed did nothing.

I downloaded a trial of a third-party app named Font Agent Pro and it also could not load these fonts.

I found a sketchy site called fonts.com and downloaded another Nubian-Medium ("ufonts.com_nubian-medium_1_.ttf") - Xcode was able to recognise that file.

I checked the permissions on these files and made sure they were rw for all, no change.

At this point you would suspect the files are just broken or corrupted but they are in use on a web page (that is also part of the project) and that works fine. What other steps could I take? What can I do to get these files added to the iOS project? If there are certain kinds of TTF that cannot be used in an iOS project, how can I check whether these are that kind?


Solution

  • The answer seems to be that these fonts were "web" fonts. I don't know how to tell the difference, given a TTF file that looks just like a "desktop" font. Learning how to do this was kind of the aim of the question.

    Practically speaking, digging out an old archive from someone's hard drive discovered another archive with TTF fonts that worked. These fonts still had 8.3 filenames and were all created as members of their own font family (so Nubian-Medium and Nubian-MediumItalic were in no way related). I renamed them, then ran them through the trial of RoboFonts to correct the family relationship. This resulted in TTFs all in the Nubian family. And then found a weird issue where a UILabel created with this font came with a 1-pixel horizontal rule at the top of the frame. Going through the process again but choosing to generate OTF output got rid of the line.

    Fonts are easy, except when they aren't, then they are really hard.