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?
To do this, add the key "Fonts provided by application" to Info. plist (the raw key name is UIAppFonts ). Xcode creates an array value for the key; add the name of the font file as an item of the array. Be sure to include the file extension as part of the name.
Select File menu > Add Files to "Your Project Name"... from the menu bar, select all the fonts you need to add, then click the Add button. Or drag the file from Finder and drop it into your Xcode project.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With