简体   繁体   中英

Custom font is not added to project

I have the same issue as described here

I have a font called ANTIQUAA.TTF. This font is added to Supporting Files of the project. In my app plist I have entry Fonts provided by application and ANTIQUAA.TTF is added there.

I can't use this font in the app. When I run this method I can't see the font.

 NSArray *familyNames = [[NSArray alloc] initWithArray:[UIFont familyNames]];
    NSArray *fontNames;
    NSInteger indFamily, indFont;
    for (indFamily=0; indFamily<[familyNames count]; ++indFamily)
    {
        NSLog(@"Family name: %@", [familyNames objectAtIndex:indFamily]);
        fontNames = [[NSArray alloc] initWithArray:
                     [UIFont fontNamesForFamilyName:
                      [familyNames objectAtIndex:indFamily]]];
        for (indFont=0; indFont<[fontNames count]; ++indFont)
        {
            NSLog(@"    Font name: %@", [fontNames objectAtIndex:indFont]);
        }
        [fontNames release];
    }
    [familyNames release];

What am I missing ?

push the add button in "Copy Bundle Resources" and click on the font files.

在此处输入图片说明

Looks like you just need to add the font resource to your .plist file.

Open your plist as text and paste:

<key>UIAppFonts</key>
<array>
        <string>ANTIQUAA.TTF</string>
</array>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM