1

Possible Duplicate:
Can I embed a custom font in an iPhone application?

I am stuck in the following problem: I have to use the following font: Helvetica Neue LT Pro . Medium condensed and Bold condensed styles.

I first had them as otf files and I read somewhere that it might be better to have them as true-type fonts. So I converted them to .ttf files using http://www.freefontconverter.com/

What I did:

1) I added the fonts in my Resources bundle , checked to be sure they are listed in Copy Bundle Resources section.

2) I added them in the Fonts provided by application entry in Info.plist with the complete name and extension of my 2 files : helveticaneueltprobdcn.ttf and helveticaneueltpromdcn.ttf

3) I used this code to check the fonts were installed and get the name:

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

4) The fonts were listed there , like this:

 FAMILY: Helvetica Neue LT Pro
   HelveticaNeueLTPro-MdCn
   HelveticaNeueLTPro-BdCn

5) Still not working when trying to use [UIFont fontWithName:@"HelveticaNeueLTPro-BdCn" size:16]. It's not the font that I asked for , I guess it does not find it and uses the system default. If I change the size , there's no change - I can use size 16 or 46 , the result is the same.

6) I tried deleting and re-installing the app , clean project in XCode , everything I could think of.

Does anyone have any idea why this wouldn't work? I googled a lot and I couldn't find a solution. If it matters , I'm using XCode 4.3.2 , iOS SDK 5.1 and running on an iPad with iOS 5.1.1 installed.

Thank you.

Regards,

George

Community
  • 1
  • 1
George
  • 4,029
  • 1
  • 23
  • 31
  • hi check out below link it might be helpful [click me :)][1] [1]: http://stackoverflow.com/questions/360751/can-i-embed-a-custom-font-in-an-iphone-application – Rushabh Sep 14 '12 at 12:18
  • have a look to your font name in font book and use the same post script name: is it still shown as HelveticaNeueLTPro-BdCn? – tiguero Sep 14 '12 at 12:37
  • Forgot to mention , I did that already . It's the same name. This stuff makes me crazy , I used custom fonts many times , I can't find a reason for it not to work now. – George Sep 14 '12 at 12:49
  • Yes honestly there is nothing else i could think of. May be just try another custom font and see if it works. – tiguero Sep 14 '12 at 12:51
  • I tried 2 other fonts , no luck there either. – George Sep 14 '12 at 13:01
  • You are using interface builder ? You can change the text by code ? If you change to a system font what happen ? – ggrana Sep 14 '12 at 14:36

1 Answers1

0

Finally got it...

Here's what I was doing:

MyCustomView *view = [[MyCustomView alloc] init];
//bla bla

In MyCustomView.m , in the init method I had this:

- (id) init
{
     //create some labels and set their fonts.
}

The problem is that at the time at which I was setting the font , the parent view of the labels ( MyCustomView instance ) was not added to a superview.

I made a setFonts method that I called after I called init on the MyCustomView instance and when I set the fonts there, it worked!

Hope this helps.

Cheers!

George
  • 4,029
  • 1
  • 23
  • 31