Xcode:即使将自定义TTF字体添加到目标中,它也不可用

时间:2017-11-22 17:35:57

标签: xcode fonts

我有一个名为Bebas Neue的自定义字体,我想添加到我的项目中。但是,当我添加这些行以打印出可用的字体列表时,它不会显示:

AppDelegate.m

  for (NSString* family in [UIFont familyNames]) {
    NSLog(@"%@", family);

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

enter image description here

资源文件夹:

enter image description here

添加到目标

enter image description here

当我在控制台中检查时,它与HelveticaNeue相同,这是我添加的另一种有效的字体:

Helvetica Neue(工作)

➜  ICOPro git:(master) ✗ ag Helvetica ios
ios/ICOPro/Info.plist
49:             <string>HelveticaNeue-CondensedBold.ttf</string>

ios/ICOPro.xcodeproj/project.pbxproj
26:             2EB9EE9250BA4D41B0A7B61B /* HelveticaNeue-CondensedBold.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 7F92E629CCFE4
A4DB2E601C5 /* HelveticaNeue-CondensedBold.ttf */; };
370:            7F92E629CCFE4A4DB2E601C5 /* HelveticaNeue-CondensedBold.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fi
leEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = "HelveticaNeue-CondensedBold.ttf"; path = "../src/assets/fonts/Hel
veticaNeue-CondensedBold.ttf"; sourceTree = "<group>"; };
556:                            7F92E629CCFE4A4DB2E601C5 /* HelveticaNeue-CondensedBold.ttf */,
1160:                           2EB9EE9250BA4D41B0A7B61B /* HelveticaNeue-CondensedBold.ttf in Resources */,

Bebas Neue(不工作)

➜  ICOPro git:(master) ✗ ag Bebas ios
ios/ICOPro/Info.plist
60:             <string>BebasNeue-Regular.ttf</string>

ios/ICOPro.xcodeproj/project.pbxproj
50:             56A87C895ECF4E1CBC2ADE48 /* BebasNeue-Regular.ttf in Resources */ = {isa = PBXBuildFile; fileRef = CF68AC43D8894DE0BC1E1C7
D /* BebasNeue-Regular.ttf */; };
393:            CF68AC43D8894DE0BC1E1C7D /* BebasNeue-Regular.ttf */ = {isa = PBXFileReference; name = "BebasNeue-Regular.ttf"; path = "..
/src/assets/fonts/BebasNeue-Regular.ttf"; sourceTree = "<group>"; fileEncoding = undefined; lastKnownFileType = unknown; explicitFileType
= undefined; includeInIndex = 0; };
567:                            CF68AC43D8894DE0BC1E1C7D /* BebasNeue-Regular.ttf */,
1172:                           56A87C895ECF4E1CBC2ADE48 /* BebasNeue-Regular.ttf in Resources */,

1 个答案:

答案 0 :(得分:0)

除了bebas neue之外,

适用于各种字体。我切换到bebas(不是neue)并且它工作了