iOS ttf fonts only partially work

fonts, ios

Solution

OpenSans Regular is just `OpenSans`, semi-bold is `OpenSans-Semibold`, etc.

In Font Book.app select the font and choose `Command + I` which brings up the font info. In the "PostScript name" in the top you can see what the font is called and how you can call it in your code.

Also, just make sure the font has actually been added in your bundle and your plist :)

Problem

I need OpenSans in my app and so I imported the whole OpenSans bunch which includes Bold, ExtraBold, Italic, Regular, Light and more. I added them to Fontbook (to check the exact name I need to address them by when using them) on my Mac, to my project in the file structure and added them in Build phases to my project as well. Now the weird thing; when I use them with UIFont, ONLY OpenSans-Bold works. The rest doesn't work. If I use OpenSans-Bold (exactly the identifier given by Fontbook), everything works fine. If I, however, change it to OpenSans-Regular or OpenSans-Light or something else in that family, I get the systemfont with UIFont and I get nothing when drawing with Quartz. All fonts are in all lists and I checked all the identifiers from Fontbook (which was why I couldn't get OpenSans-Bold working), but now i'm at a loss. Any idea what I could be doing wrong?

Original source

Related problems