iPad2 SDK 4.x 自定义 UIFonts 未显示在列表中?
我按照一些说明添加了自定义字体,建议将它们添加到 plist.info 的“应用程序提供的字体”键下,据说神奇的事情发生了并且它起作用了。但是,我编写此代码片段是为了转储字体,但我看不到自定义字体,只看到现有的应用程序字体。我将代码放在我的应用程序委托中:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
...
// Snippet to dump the list of fonts in the system.
for (id objFamilyName in [UIFont familyNames]) {
if ([objFamilyName isKindOfClass:[NSString class]]) {
for(id objFontName in [UIFont fontNamesForFamilyName:(NSString*)objFamilyName]) {
if ([objFontName isKindOfClass:[NSString class]]) {
NSLog(@"%s: %@: %@", __FUNCTION__, objFamilyName, objFontName);
}
}
}
}
同样,如果我尝试加载指定字体,它不会产生任何效果。
我的设置如下所示(字体名称类似于“cssbook.ttf”
I added custom fonts by following some instructions suggesting add them to plist.info under the key "Fonts provided by application" and supposedly magic happens and it works. But, I wrote this snippet to dump the fonts and I do not see my custom fonts, just the existing app fonts. I put the code in my app-delegate here:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
...
// Snippet to dump the list of fonts in the system.
for (id objFamilyName in [UIFont familyNames]) {
if ([objFamilyName isKindOfClass:[NSString class]]) {
for(id objFontName in [UIFont fontNamesForFamilyName:(NSString*)objFamilyName]) {
if ([objFontName isKindOfClass:[NSString class]]) {
NSLog(@"%s: %@: %@", __FUNCTION__, objFamilyName, objFontName);
}
}
}
}
Likewise, if I try to load the named font, it does not have any effect.
My settings look like this (font names are like "cssbook.ttf"
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先,加载字体册并检查字体名称/系列到底是什么。然后将实际的 .ttf 文件添加到您的应用程序中,以便您的应用程序在运行时可用。
First, load Font Book and check to see exactly what the font name / family is. then add the actual .ttf file to your application so that it is available to your app at runtime.