简体   繁体   English

自定义字体未添加到项目

[英]Custom font is not added to project

I have the same issue as described here 我有与此处所述相同的问题

I have a font called ANTIQUAA.TTF. 我有一种叫做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. 在我的应用程序列表中,我输入了应用程序提供的字体,并在其中添加了ANTIQUAA.TTF。

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. 看起来您只需要将字体资源添加到.plist文件即可。

Open your plist as text and paste: 打开您的plist作为文本并粘贴:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在项目中添加了自定义字体,但是当我尝试使用它们时,出现“严重错误:在展开可选值时意外发现nil” - Added custom font to project but when I try and use them I get a “fatal error: unexpectedly found nil while unwrapping an Optional value” 自定义.plist文件未添加到ios项目 - Custom .plist file not added to ios project 添加自定义字体(Impact)到iOS项目不起作用 - Adding custom font (Impact) to iOS project not working 无法将自定义字体包含到xcode项目中 - Cannot include custom font into xcode project 找不到添加到xcode 7的自定义字体的名称 - can't find the name of custom font added to xcode 7 我们是否需要为 flutter ios 项目添加 firebase 自定义代码 - Do we need to added firebase custom code for flutter ios project 自定义字体在“界面生成器”中可见,但在iOS项目中的代码中则未 - Custom font seen in Interface builder but not in code in iOS project 如何在我的xcode项目中添加和使用自定义字体 - How to add and use a custom font in my xcode project 无法在Cocos2d-x项目中使用自定义字体 - Cannot use custom font in Cocos2d-x project 将自定义字体添加到项目,以编程方式将项目添加到plist - Adding custom font to project, programmatically add item to plist
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM