• Did you order new AirTags? We've opened a dedicated AirTags forum.

erdinc27

macrumors regular
Original poster
Jul 20, 2011
168
1
i want to use a custom font for my application. i added font file to my app and the in info.plist i added a new row Fonts Provided By Application as an array and added my font OpenSansBold.ttf. and the font file can be seen in Build Phases also. In the table view cell i want to use that font so i wrote this.
Code:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *cellID = @"HaberCell";
    
    HaberCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
    
    if (cell == nil)
    {
        cell = [[HaberCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
    }
    
    Haber *currentHaber = [self.arrHaberler objectAtIndex:indexPath.row];

    cell.haberLbl.text = currentHaber.haberTitle;

    cell.haberLbl.font = [UIFont fontWithName:@"OpenSansBold" size:12];

    return cell;
}

but it cant be seen in the right font format. how can i change the label's font here ?
 
Last edited:

dantastic

macrumors 6502a
Jan 21, 2011
570
677
you're doing it right but it can be tricky to know what a font is actually named.

start by logging this fella
Code:
[UIFont familyNames]

Then find the font family you're after in the list and print out this fella
Code:
[UIFont fontNamesForFamilyName:@"myFont"]

That will tell you what you should name the font you are trying to load.
 
Comment

D.T.

macrumors G4
Sep 15, 2011
11,051
12,442
Vilano Beach, FL
Yeah, it’s the internal font name, not the TTF filename. A quick search seems to indicate this font name should be:

OpenSans-Bold
 
Comment

erdinc27

macrumors regular
Original poster
Jul 20, 2011
168
1
thanks for the help guys. i solved the problem by your suggestions
 
Comment
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.