iOS中自定义字体的问题

时间:2012-03-17 13:04:09

标签: ios ios5 uilabel uifont custom-font

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

[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(@"Available fonts: %@", [UIFont familyNames]);会返回:

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

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

1 个答案:

答案 0 :(得分:5)

列出所有字体

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