2

我正在尝试在我的应用程序中嵌入自定义字体。

我已经在我的项目中包含了字体文件

我将密钥添加到 .plist

我将字体添加到目标

的结果:

NSLog(@"Fonts: %@", [UIFont familyNames]);

Fonts: (
Thonburi,
"Snell Roundhand",
"Academy Engraved LET",
Avenir,
"Marker Felt",
"Geeza Pro",
"Arial Rounded MT Bold",
"Trebuchet MS",
Arial,
Marion,
"Gurmukhi MN",
"Malayalam Sangam MN",
"Bradley Hand",
"Kannada Sangam MN",
"Bodoni 72 Oldstyle",
Cochin,
"Sinhala Sangam MN",
"Hiragino Kaku Gothic ProN",
Papyrus,
Verdana,
"Zapf Dingbats",
"Avenir Next Condensed",
Courier,
"Hoefler Text",
Helvetica,
"Euphemia UCAS",
"Hiragino Mincho ProN",
"Bodoni Ornaments",
"Apple Color Emoji",
Optima,
"Gujarati Sangam MN",
"Devanagari Sangam MN",
"Times New Roman",
Kailasa,
"Telugu Sangam MN",
"Heiti SC",
"Apple SD Gothic Neo",
Futura,
"Bodoni 72",
Baskerville,
"Chalkboard SE",
"Heiti TC",
Copperplate,
"Party LET",
"American Typewriter",
Symbol,
"Avenir Next",
Noteworthy,
"Bangla Sangam MN",
Zapfino,
"Tamil Sangam MN",
Chalkduster,
"Arial Hebrew",
Georgia,
"Helvetica Neue",
"Gill Sans",
Palatino,
"Courier New",
"Oriya Sangam MN",
Didot,
"Bodoni 72 Smallcaps"
)

我的字体没有在那里列出,这是我正在使用的代码:

[UIFont fontWithName:@"KozGoPr6N-Regular.ttf" size:self.LabelEmail.font.pointSize];

使用上面的代码字体的大小并不总是改变,只是在某些时候。

IE,当我用 0.20 替换 self.LabelEmail.font.pointSize 时,大小保持完全相同,标签连接为 IB 的 IBOutlet 并且字体在 IB 中设置为 14 点

4

1 回答 1

1
[UIFont fontWithName:@"KozGoPr6N-Regular.ttf" size:self.LabelEmail.font.pointSize];

首先,我很确定“.ttf”不是(内部)字体名称的一部分。

代码应如下所示:

[UIFont fontWithName:@"KozGoPr6N-Regular" size:self.LabelEmail.font.pointSize];

其次,您是否自己将这种字体从 OpenType (.otf) 转换为 TrueType (.ttf)?(我在我的机器上进行了快速搜索,发现此字体存在,但它是安装在 /Library/Fonts/ 中的 OpenType 字体)。

于 2013-01-24T13:57:12.187 回答