Search code examples
iphoneobjective-cios5xcode4.2objective-c++

custom font not working on iphone device


I am trying to load an external .ttf font into one of my iOS projects. The font works fine within an emulator, but fails to display on an actual device.

I am using the LLVM GCC 4.2 compiler. In another project, with the Apple LLVM compiler 3.0, the same font works. I do not understand how I can fix it? What are the steps I need to follow with the LLVM GCC 4.2 compiler?


Solution

  • For the Custom font below code help

    UILabel *label1 = [[UILabel alloc] initWithFrame:CGRectMake(10, 30, 240, 40)];
    [label1 setFont: [UIFont fontWithName: @"Grinched" size:24]];
    [label1 setText:@"Grinched Font"];
    [[self view] addSubview:label1];
    
    UILabel *label2 = [[UILabel alloc] initWithFrame:CGRectMake(10, 80, 240, 40)];
    [label2 setFont: [UIFont fontWithName: @"Energon" size:18]];
    [label2 setText:@"Energon Font"];
    [[self view] addSubview:label2];
    

    Also u can download sample code and tutorial here.