Adding multiple fonts to UIAppFonts overrides each other

痴心易碎 提交于 2019-12-22 05:25:15

问题


I'm trying to add some custom fonts to an iPhone app through UIAppFonts in Info.plist.

I can reach both fontnames by code, i.e. MyFont-Bold and 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.

The property list excerpt:

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?


回答1:


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.




回答2:


I had a similar issue with multiple fonts of the same font family. I found that if I viewed the info.plist file as source code, the xml not formatted properly which cause only some of the fonts to register.



来源:https://stackoverflow.com/questions/4245960/adding-multiple-fonts-to-uiappfonts-overrides-each-other

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!