简体   繁体   English

UIAppFonts是否自动加载字体?

[英]UIAppFonts load automatically the font?

I am trying to use a custom font in my iPhone app but somehow it does not load I believe at all in the app as a start to my problem. 我正在尝试在我的iPhone应用程序中使用自定义字体,但是某种程度上它无法加载,我认为该应用程序完全可以解决我的问题。

I dragged and dropped the "My Font.ttf" in xcode and create the key with UIAppFonts. 我将“ My Font.ttf”拖放到了xcode中,并使用UIAppFonts创建了密钥。 First question: I guess the these 2 names should be strictly identical ie my key must display the the exact filename and so with the extension ".ttf"...? 第一个问题:我猜这两个名称应严格相同,即我的密钥必须显示确切的文件名,因此扩展名为“ .ttf” ...? what about if upper/lower case? 大写/小写怎么办? what about if there are spaces in the filename...? 如果文件名中有空格怎么办?

Then I use this: 然后我用这个:

NSArray *familyNames = [[NSArray alloc] initWithArray:[UIFont familyNames]];
NSLog(@"Fonts: %@", [UIFont familyNames]);
[familyNames release];

to display all the fonts and clearly see that my font is NOT there.... 显示所有字体并清楚地看到我的字体不存在。

Then so when I use that below, nothing works (for sure): 然后,所以当我在下面使用它时,没有任何效果(肯定):

lblSol1.font = [UIFont fontWithName:@"My Font" size:32];

(if I replace by Arial, it does work so I can only think it has to do with the loading of the font...) (如果我用Arial代替,它确实起作用,所以我只能认为它与字体的加载有关。)

I understood that the name to use with -fontWithName can be different that filename (and is actually the name of the font "fullname" when you open in the get info window). 我了解到-fontWithName使用的名称可以与文件名不同(当在获取信息窗口中打开时,实际上是字体“全名”的名称)。 Anyway, I by now tried all combinations and can't get it to work... 无论如何,我现在尝试了所有组合,但无法正常使用...

(I also did deploy and build for iOS 4.o to be sure to be far from 3.2 in case of..) (我也确实为iOS 4.o进行了部署和构建,以确保在3.2的情况下不会离3.2太远。)

Thanks for your help. 谢谢你的帮助。

Cheers, geebee 干杯,吉蜂

EDIT1: the result (as asked) of showing the fonts is: Fonts: ( "Arial Hebrew", Zapfino, "Oriya Sangam MN", Cochin, Baskerville, Palatino, "Chalkboard SE", "Gurmukhi MN", Verdana, "Tamil Sangam MN", "Marker Felt", "Courier New", Courier, "Trebuchet MS", "DB LCD Temp", "Apple Color Emoji", "Arial Rounded MT Bold", "Bangla Sangam MN", "Telugu Sangam MN", "American Typewriter", Arial, Kailasa, AppleGothic, "Hiragino Kaku Gothic ProN", "Heiti SC", "Malayalam Sangam MN", Thonburi, Helvetica, Noteworthy, "Gujarati Sangam MN", "Heiti K", Futura, "Devanagari Sangam MN", "Heiti TC", "Sinhala Sangam MN", "Kannada Sangam MN", Georgia, "Heiti J", "Times New Roman", "Snell Roundhand", "Geeza Pro", "Helvetica Neue" EDIT1:显示字体的结果(根据要求)是:字体:(“ Arial Hebrew”,Zapfino,“ Oriya Sangam MN”,Cochin,Baskerville,Palatino,“ Chalkboard SE”,“ Gurmukhi MN”,Verdana,“ Tamil Sangam MN”,“ Marker Felt”,“ Courier New”,Courier,“ Trebuchet MS”,“ DB LCD Temp”,“ Apple Color Emoji”,“ Arial Rounded MT Bold”,“ Bangla Sangam MN”,“ Telugu Sangam MN” ”,“美国打字机”,Arial,Kailasa,AppleGothic,“ Hiragino Kaku Gothic ProN”,“ Heiti SC”,“ Malayalam Sangam MN”,吞武里,Helvetica,值得注意的“ Gujarati Sangam MN”,“ Heiti K”,Futura, “ Devanagari Sangam MN”,“ Heiti TC”,“ Sinhala Sangam MN”,“ Kannada Sangam MN”,乔治亚州,“ Heiti J”,“ Times New Roman”,“ Snell Roundhand”,“ Geeza Pro”,“ Helvetica Neue”

According to the documentation here: UIAppFonts 根据此处的文档: UIAppFonts

UIAppFonts (Array - iOS) specifies any application-provided fonts that should be made available through the normal mechanisms. UIAppFonts(Array-iOS)指定应通过常规机制提供的任何应用程序提供的字体。 Each item in the array is a string containing the name of a font file (including filename extension) that is located in the application's bundle. 数组中的每个项目都是一个字符串,其中包含位于应用程序捆绑包中的字体文件(包括文件扩展名)的名称。 The system loads the specified fonts and makes them available for use by the application when that application is run. 系统加载指定的字体,并在运行该应用程序时将其提供给应用程序使用。

This key is supported in iOS 3.2 and later. iOS 3.2及更高版本支持此键。

So yes, you need to include the filename extension. 因此,是的,您需要包括文件扩展名。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM