0

I recently posted Why is this label appearing unstyled? , and besides trying to work things out, have gone through some well-upvoted questions, including Use custom fonts in iPhone App , and others.

What I have done is:

  1. Install Scurlock.TTF, installing it under the "Supporting files" folder. (Note: this is a best approximation as, while the question quoted above shows a "Resources" folder in its screenshot and said to be sure to put the font into the "Resources" folder. Maybe things have changed since that posting?)

  2. Edit my info.plist file to add:

    <key>Fonts provided by application</key>
    <array>
    <string>Scurlock.TTF</string>
    </array>
    
  3. Attempt to access Scurlock by the likes of:

    UIFont *font = [UIFont fontWithName:@"Scurlock" size:40];
    UIFont *font = [UIFont fontWithName:@"Scurlock.TTF" size:40];
    
  4. Run code that was suggested to me according to Why is this label appearing unstyled?:

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

    This gave a long list of fonts, including one zero which I suspect may be a corrupt family, possibly a corrupt Scurlock.

I wanted to check both if the font (linked above) is corrupt (Font Squirrel had little trouble generating a webfont.zip from it, which is a sanity check at least), or whether the older articles recommended--all much further back than iOS 7--gave a dated answer.

How, in Xcode 5 and iOS 7, can I install a font (anywhere besides listing it under "Supporting Files")?, notify the system of its presence (such as defining the plist's only "Fonts provided by application" value), and use the font from my code, or otherwise do something that will work with my system and iOS 7?

Community
  • 1
  • 1
Christos Hayward
  • 5,777
  • 17
  • 58
  • 113
  • http://stackoverflow.com/questions/18413332/uifont-woes-some-custom-fonts-loading-but-others-are-not?rq=1 says that similar things can happen if you use the filename when you should be using the font's name. Can anybody tell whether the Scurlock.TTF has a name of Scurlock or something else? – Christos Hayward Oct 03 '13 at 19:35
  • 1
    1. The link doesn't work 2. Edit the question instead of commenting it 3. Look up the font name at the Font Book app. – A-Live Oct 03 '13 at 20:48
  • agree to 1-3 and adding: I dont get your problem at all ^^ – Daij-Djan Oct 03 '13 at 21:58
  • 1
    btw nothing changed for custom font handling in ios7 -- works just as before – Daij-Djan Oct 03 '13 at 21:59
  • The font's name does actually appear to be 'Scurlock': the link to the TTF in the question worked for me; renaming the file just to be sure I don't read the wrong box in haste and opening it in Font Book gives a window titled 'Scurlock'. Command+i also shows "Full Name: Scurlock". Highlighting that showed no spurious whitespace around the outside. – Tommy Oct 04 '13 at 00:52

1 Answers1

1

Your info.plist should look like:

<key>UIAppFonts</key>
<array>
<string>Scurlock.TTF</string>
</array>

The key is UIAppFonts. Xcode will display that as "Fonts provided by application" if you're an English-speaking user but it's not the correct info.plist key.

Tommy
  • 99,986
  • 12
  • 185
  • 204