0

I'm trying to load a font into an application. I think I'm doing it well. But it doesn't work on iOS < 5.0.

I'm included the font files as resources (using otf files), add them to UIAppFonts array and testing the fonts on buttons. Like this:

In Info.plist:

<key>UIAppFonts</key>
    <array>
        <string>FrutigerNextPro-Medium.otf</string>
        <string>FrutigerNextPro-MediumIta.otf</string>
        <string>FrutigerNextPro-Light.otf</string>
        <string>FrutigerNextPro-LightIta.otf</string>
    </array>

Them in the buttons like this:

btt_01.titleLabel.font = [UIFont fontWithName:@"FrutigerNextPro-Medium" size:20];
btt_02.titleLabel.font = [UIFont fontWithName:@"FrutigerNextPro-MediumIta" size:20];
btt_03.titleLabel.font = [UIFont fontWithName:@"FrutigerNextPro-Light" size:20];
btt_04.titleLabel.font = [UIFont fontWithName:@"FrutigerNextPro-LightIta" size:20];

The problem is that FrutigerNextPro-Medium and FrutigerNextPro-MediumIta are only loaded in devices and simulator using iOS >= 5.0. In devices and simulator with iOS < 5.0 it doesn't loads the font, I think it loads FrutigerNextPro-Light

and When I Log like this:

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

I get the font available in any platform:

 (
    "FrutigerNextPro-MediumIta",
    "FrutigerNextPro-LightIta",
    "FrutigerNextPro-Medium",
    "FrutigerNextPro-Light"
)

I get the font available in any platform.

Can someone help me trying to understand what's going wrong.

Thanks

Frade
  • 2,938
  • 4
  • 28
  • 39
  • I believe OTF fonts were not officially supported in earlier versions of iOS. You can probably use a tool to convert these fonts to TTF. – Mike Weller Apr 02 '12 at 13:21
  • if it so why FrutigerNextPro-Light is loaded and FrutigerNextPro-Medium not?? both are in otf format.. don't understand what is happening.. – Frade Apr 02 '12 at 14:13
  • Already converted all fonts to ttf, still having the same issue.. – Frade Apr 02 '12 at 15:09

2 Answers2

0

if you want to add custom font for older version of iOS then use this approch Can I embed a custom font in an iPhone application?

Community
  • 1
  • 1
priyanka
  • 2,076
  • 1
  • 16
  • 20
0

I discovered that it's a limitation, that only 2 variants of a single font face is supported.

Check this: http://www.iphonedevsdk.com/forum/iphone-sdk-development/59855-ipad-custom-font-issue.html

But still with no solution.. still unable to load FrutigerNextPro-Medium in iOS < 5.0.. I will try to convert the font..

EDIT: I converted all fonts to ttf, but don't believe that was the solution.

What I did was (like in the forum says) change the Font Family Name.

Then I realize that is true, it's an issue, can't have 2 variants of a single font family.

Now its working.

Thanks anyway

Frade
  • 2,938
  • 4
  • 28
  • 39