问题描述
我正在尝试通过 Info.plist
中的 UIAppFonts
向iPhone应用程序添加一些自定义字体.
I'm trying to add some custom fonts to an iPhone app through UIAppFonts
in Info.plist
.
我可以通过代码(即 MyFont-Bold
和 MyFont-Medium
)获得两种字体名称.
I can reach both fontnames by code, i.e. MyFont-Bold
and MyFont-Medium
.
我的问题是 UIAppFonts
数组中的最后一种字体会覆盖另一个字体,从而使 MyFont-Bold
和 MyFont-Medium
都呈现出来 MyFont-Bold
(如果这是plist数组中的最后一个条目).通过拖动 MyFont-Bold
作为第一项,使两个字体名称都呈现MyFont-Medium.
My problem is that the last font in UIAppFonts
array overrides the other one, making both MyFont-Bold
and MyFont-Medium
render out MyFont-Bold
if this is the last entry in the plist array. By dragging MyFont-Bold
as the first entry makes both font-names render MyFont-Medium.
属性列表摘录:
UIAppFonts
item 0 MyFont-Medium
item 1 MyFont-Bold
我用以下字体调用字体:
I'm calling the font with:
UIFont* applicationFontBold = [UIFont fontWithName:@"MyFont-Bold"
size:[UIFont buttonFontSize]];
UIFont* applicationFont = [UIFont fontWithName:@"MyFont-Medium"
size:[UIFont buttonFontSize]];
有人尝试将多个字体添加到一个字体家族吗?
Anyone tried adding multiple fonts to one font-family?
推荐答案
不知道它是否已修复,但我通过使用vim编辑器实际修改.ttf文件中的字体系列名称来解决此问题.因为您具有不同的字体类型(粗体和中型),但实际上是相同的字体家族(MyFont),所以系统将它们混合在一起.因此,我在第一个文件中执行的操作-实际上将家族更改为MyFontA,而在第二个文件中将MyFontB修改了(当然,我有不同的名称-这些只是与上面的示例匹配).这很完美.
Don't know if it was ever fixed, but I worked around this issue by actually modifying the font family names inside the .ttf files, using vim editor. Because you have different font-types (Bold and Medium) but actually the same fontfamily (MyFont) - the system mixes them up. So what I did in the first file - I actually modified the family to be MyFontA, and in the second file MyFontB (of course I had different names - these are just to match the example above).This worked perfect.
这篇关于向UIAppFonts添加多种字体会相互覆盖的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!