1
我在Xcode 4.6.3中安装自定义字体(来自Google Fonts)的问题。我做了以下内容:在Xcode 4.6.3中安装自定义字体
- 下载我的字体从谷歌字体
- 我的Mac上安装它,这样我可以得到它的系统名称
- 拖我的字体文件(Inconsolata.ttf)进入“支持Xcode中的文件“文件夹
- 转到我的
Info.Plist
文件,并将Inconsolata.tff添加为UIAppFonts阵列中的项目。 - 尝试在字体列表打印出我安装的字体使用
- 尝试使用我的自定义字体,它的全名,我在Finder中发现
第5步:打印出所有UIFonts:
// When I search for "Inconsolata" in my Debug Console, it returns nothing
// Therefore I think that the font simply isn't being installed...
for (NSString *familyName in [UIFont familyNames]) {
for (NSString *fontName in [UIFont fontNamesForFamilyName:familyName]) {
NSLog(@"%@", fontName);
}
}
第6步:使用自定义UIFont:
// this line doesn't work.
cell.textLabel.font = [UIFont fontWithName:@"Inconsolata" size:15];
// this line works. it changes font to Helvetica-Bold
// cell.textLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:15];