1

hi i am using custom font xcode 5. its font family name is "Alegre Sans" i follow many tutorials online of using custom font in xcode.

I have include custom font file name "alegre.ttf" in xcode resources folder. also i include this file in project .plist under "Fonts provided by applications". and i am using this fond in viewdidload method of viewcontroller like this

CustomLabel* lblObj = [[CustomLabel alloc]initWithFrame:CGRectMake(121, 30, 0, 0)];

[lblObj setText:@"FREE TRAIL"];
[lblObj sizeToFit];
[lblObj setFont:[UIFont fontWithName:@"Alegre Sans" size:10.0]];


//  [headerLabel setFont:[UIFont boldSystemFontOfSize:30.0]];
[lblObj setTextColor:[UIColor whiteColor]];
[lblObj setTextAlignment:NSTextAlignmentCenter];
[self.headerBgVw addSubview:lblObj];

but unable to change font.

I have wasted my whole day on it but not able to change font . is i am doing mistake in programing or including font file

E.S
  • 536
  • 1
  • 9
  • 20
user3110557
  • 13
  • 1
  • 3
  • Possible duplication:http://stackoverflow.com/questions/13029660/use-custom-fonts-in-iphone-app – Dhaval Bhadania Dec 17 '13 at 09:46
  • try rename alegre.ttf by 'Alegre-Sans' and use `[UIFont fontWithName:@"Alegre-Sans" size:10.0]]` – johnMa Dec 17 '13 at 09:50
  • When you use a custom font, the name you use in `fontWithName:size:` should be the fully-specified name of the font. This can help enumerate the fonts available to the application by their usable name: http://stackoverflow.com/questions/8963299/cant-find-custom-font-ios – FluffulousChimp Dec 17 '13 at 09:56
  • pls see this answer http://stackoverflow.com/questions/20416184/using-fonts-ttf-or-odf-in-ios-applications-is-it-a-hit-or-miss-whether-they/20416481#20416481 – manujmv Dec 17 '13 at 09:58

1 Answers1

6

The font's postscript name is AlegreSans

Update this line

[lblObj setFont:[UIFont fontWithName:@"Alegre Sans" size:10.0]]:

to

[lblObj setFont:[UIFont fontWithName:@"AlegreSans" size:10.0]];
nomann
  • 2,257
  • 2
  • 21
  • 24