Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIFont fontWithName: limited to loading 2 variations per family

This question is extremely similar to UILabel with custom font displays *wrong* custom font, except I need to use three fonts from this family simultaneously. I am using Myriad Pro, just like that question, but I need to use Bold, Semibold, and Regular.

Currently, when I try to use Bold via a macro defined as:

#define MYRIAD_BOLD(x) [UIFont fontWithName:@"MyriadPro-Bold" size:(x)]

..it gives me Semibold. If I remove Semibold from the plist entries for "Fonts provided by application" (as is the "answer" for the similar question linked above), Bold is correctly returned, but (obviously) Semibold is no longer usable.

Any ideas as to why I would (seemingly) be limited to two custom fonts at once? (from the same family, at least?)

BTW, here is the NSLog output for [UIFont fontNamesForFamilyName:@"Myriad Pro"]:

Myriad Pro font names: ( "MyriadPro-Semibold", "MyriadPro-Regular", "MyriadPro-Bold" )

Thanks!

like image 453
Ben Mosher Avatar asked Jan 17 '11 17:01

Ben Mosher


1 Answers

In a bizarre but somewhat anticipated workaround, I found that I could actually use a third variation by opening the font up in an editor (I just grabbed the first one I found) and changing the family name, repackaging it as an otf, and adding the new file to the application plist. I left the fontName the same.

The bizarre part is that it still loads with the same font name and shows up under the +fontNamesForFamilyName: response for Myriad Pro.

like image 173
Ben Mosher Avatar answered Sep 30 '22 05:09

Ben Mosher