2013-07-20 39 views
1

我在Xcode 4.6.3中安装自定义字体(来自Google Fonts)的问题。我做了以下内容:在Xcode 4.6.3中安装自定义字体

  1. 下载我的字体从谷歌字体
  2. 我的Mac上安装它,这样我可以得到它的系统名称
  3. 拖我的字体文件(Inconsolata.ttf)进入“支持Xcode中的文件“文件夹
  4. 转到我的Info.Plist文件,并将Inconsolata.tff添加为UIAppFonts阵列中的项目。
  5. 尝试在字体列表打印出我安装的字体使用
  6. 尝试使用我的自定义字体,它的全名,我在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]; 

回答

2

固定通过将字体文件时,像这样

enter image description here

加入目标