I'm trying to get a set of Neo Sans Pro fonts working on the iPhone. I have four weights: Light, Regular, Medium, Bold as OTF files (NeoSansPro-Light.otf, -Regular.otf etc). The files are included in the build, and registered in the info.plist.
Calling [UIFont fontNamesForFamilyName:@"Neo Sans Pro"]
returns an array with 4 entries e.g. "NeoSansPro-Light".
I can retrieve font objects for each of these strings using UIFont fontWithName:size:
.
However, when I draw text with them, the Light, Regular and Medium versions all draw exactly the same, and look like the Light version. The Bold version draws differently.
According to Font Book, each font file does contain different glyphs.
I'm completely stumped - any clues what I need to do?
[Added] Some more investigation:
NSArray *fonts = [UIFont fontNamesForFamilyName:@"Neo Sans Pro"];
for (NSString *fname in fonts) {
UIFont *font = [UIFont fontWithName:fname size:12.0];
NSLog(@"name: %@ font: %@", fname, font);
}
Running this code gives the following log output:
name: NeoSansPro-Light font: <UICFFont: 0x66304a0> font-family: "Neo Sans Pro"; font-weight: normal; font-style: normal; font-size: 12px
name: NeoSansPro-Regular font: <UICFFont: 0x66304a0> font-family: "Neo Sans Pro"; font-weight: normal; font-style: normal; font-size: 12px
name: NeoSansPro-Medium font: <UICFFont: 0x66304a0> font-family: "Neo Sans Pro"; font-weight: normal; font-style: normal; font-size: 12px
name: NeoSansPro-Bold font: <UICFFont: 0xaa06070> font-family: "Neo Sans Pro"; font-weight: bold; font-style: normal; font-size: 12px
So the three fonts that display the same really are the same. But there's four font weights and four fonts in the build.
You can install any TrueType (. ttf) or OpenType (. otf) font file on your iPad or iPhone. You can then use this font in most apps like GoodNotes, Procreate, Pages, Keynote, and more.
The iPhone, however, gives you a single font. If the font changes, it's because the app you have open changed it, not you. But that doesn't mean you can't edit the text at all. Every iPhone lets you change the font size, making it either bigger or smaller.
You can download fonts from the App Store app , then use them in documents you create on iPhone. After you download an app containing fonts from the App Store, open the app to install the fonts. To manage installed fonts, go to Settings > General, then tap Fonts.
Looks like this is the same problem as here: Including multiple fonts of the same family in an iPad application
It seems the iOS font architecture gets confused if there are multiple fonts in the same font family, and won't hand back the right font. The solution is to manually edit the font family information (using something like Font Forge to different values.
E.g. For the Neo Sans Pro Light font, set the Font family (in the PSNames and TTF Names) to "NSP Light". Do similarly for Neo Sans Pro Regular -> NSP Regular etc.
You can then refer to the font by the original name e.g. "NeoSansPro-Light"
Ugly, but it works.
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