Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why specifically do custom fonts generally fail to display correctly in iOS?

I have created a number of different applications with custom fonts. I've used about six different ones, all from different sources. Each of them had problems when displayed in iOS. With some of them they drew in UILabels either higher or lower than a system font of the same size. Others drew differently in UILabels when compared to how they drew in UITextFields, drawing smaller and lower in UITextFields. Virtually all of them draw differently in UITextFields when they are being edited vs when they are not, giving an effect of the text jumping downwards when the UITextField enters edit mode. For someone doing fine detail work that needs to be pixel-perfect this is pretty bad.

My question is simply this--what in these fonts specifically causes these types of issues? Is there some specific attribute that the system font has that these other fonts do not?

For extra credit, I would love to hear any general purpose solutions that can solve these issues for every font, if such a thing is possible. My hope is that if I can understand why this is happening I can create a script to preprocess the font before packaging it with the application so that it works correctly.

These problems are easy to reproduce, but since I know someone will ask, I will list a few specific fonts that have produced problems for me:

  • PT Sans Bold
  • Avenir Next LT Pro Medium Condensed
  • Korolev Condensed Medium
like image 385
Micah Hainline Avatar asked Oct 11 '12 22:10

Micah Hainline


People also ask

How use OTF font in iOS?

Add the Font File to Your Xcode Project To add a font file to your Xcode project, select File > Add Files to “Your Project Name” from the menu bar, or drag the file from Finder and drop it into your Xcode project. You can add True Type Font (. ttf) and Open Type Font (. otf) files.

How do you change the font on iOS?

To manage installed fonts, go to Settings > General, then tap Fonts.


1 Answers

Have you tried using the Apple Font Tool Suite command line utilities? You can adjust the baseline properties of fonts with it (I acknowledge this doesn't answer the 'why' component of your question, however the tools may make the question moot). The accepted answer here does a terrific job of explaining their usage.

like image 172
NSTJ Avatar answered Oct 12 '22 03:10

NSTJ