iOS中自定义字体的问题

问题描述:

我使用 UIAppFonts 属性列表键,按照各个位置列出的步骤进行操作。我正在使用Aller Light字体。我已经将它添加为资源,在info属性列表中正确添加了字体名称,现在我正在尝试使用它,但是每次尝试都会导致显示默认字体。到目前为止,我已经尝试过:

I followed the steps outlined in various locations using the UIAppFonts property list key. I'm using the Aller Light font. I've added it as a resource, added the font name correctly in the info property list, and am now attempting to use it, however every attempt to do so results in the default font being displayed. So far I've tried:

[leader setFont:[UIFont fontWithName:@"Aller Light" size:20.0]];
[leader setFont:[UIFont fontWithName:@"AllerLight" size:20.0]];
[leader setFont:[UIFont fontWithName:@"Aller-Light" size:20.0]];
[leader setFont:[UIFont fontWithName:@"Aller-Lt.ttf" size:20.0]];

leader.font = [UIFont fontWithName:@"Aller Light" size:20.0];
... with all the variants listed above

它们都不起作用。运行 NSLog(@可用字体:%@,[UIFont familyNames]); 返回:

None of them work. Running NSLog(@"Available fonts: %@", [UIFont familyNames]); returns:

Available fonts: (
    ...
    "Aller Light",
    ...
)

想法或解决方案?在我的Mac上安装字体并查看Font Book,字体名称是Aller Light。验证字体簿中的字体表示字体名称实际上只是Aller Light。

Thoughts or solutions? Installing the font on my mac and looking in Font Book, the name of the font is Aller Light. Verifying the font in Font Book indicates that the font name is in fact simply Aller Light.

列出所有字体

for (NSString *name in [UIFont familyNames]) {
    NSLog(@"Family name : %@", name);
    for (NSString *font in [UIFont fontNamesForFamilyName:name]) {
        NSLog(@"Font name : %@", font);             
    }
}