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?
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.
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