开发者

Custom font for iPad - iOS 3.2 isn't working

I'm building an iPad-Only application. I need to use a custom font with some labels, so I added them to my project. They appear in my application target for "Copy Bundle Resources". I also added their names to my App's -Info.plist file:

<key>UIAppFonts</key>
<array>
    <string>font1.ttf</string>
    <string>font2.ttf</string>
    <string>font3.ttf</string>
    <string>font4.ttf</string>
</array>

Even so, when I try to set the font of my labels, it seems to just use the default. I haven't been able to figure out how to overcome this issue. Any assistance would be greatly appreciated.


Edit:

- (void)debug {
    NSLog(@"fonts: %@", [UIFont familyNames]);
    UIFont *f1 = [UIFont fontWithName:@"Helvetica" size:20];
    UIFont *f2 = [UIFont fontWithName:@"font1" size:5];
    NSLog(@"f1:%@开发者_运维百科 f2:%@", f1, f2);
}

And the output: http://pastie.org/1323195


How are you setting the font?

You need to use it as follows....

UIFont *myCustomFont = [UIFont fontWithName:@"font1" size:30];


The solution ended up being to use a different font. I opened the font with FontForge and got this warning:

This font is marked with an FSType of 2 (Restricted License). That means it is not editable without the permission of the legal owner.

This seems to be the cause of my issues. I downloaded a free version of the font I was trying to use (luckily it was available for free) and everything started working perfectly.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜