Dick Lucas
Dick Lucas

Reputation: 12639

Android 5.0 (API 21) fails to render custom fonts / typefaces

Android 5.0 seems to have trouble rendering custom fonts. This issue does not occur pre Android 5.0 and it does not occur in Android 5.1 (API 22). Here is an example using a font called "coaster", available here: http://www.dafont.com/coaster.font

API 21: enter image description here

API 22: enter image description here

Any explanation for this?

Upvotes: 3

Views: 1929

Answers (1)

Dick Lucas
Dick Lucas

Reputation: 12639

Google has acknowledged that this was an issue in Android 5.0, and has fixed it in Android 5.1: https://code.google.com/p/android-developer-preview/issues/detail?id=608&thanks=608&ts=1404735239

As for getting custom fonts to work on Android 5.0, there is a recommended work around in the issue page that I linked to above. It is post #16 on the issue. You need to convert your TTF font file to TTX and then convert it from TTX to TTF. You can use this tool to do so: https://github.com/behdad/fonttools/

I found these guides to be helpful for setting up fonttools:

Windows: http://glyphrstudio.com/ttx/

OSX:http://www.fontgeek.net/blog/?p=435

After installed, in terminal or the command prompt navigate to the directory where your TTF file is and run the command:

ttx font_file.ttf

Where "font_file" is the name of your, well, font file. This will output a font_file.ttx file in the directory you are currently in. Then, on this new font_file.ttx file, simply run the command:

ttx font_file.ttx

This will output a new TTF file of your font, and you can use this one in your Android project. These steps worked for me.

Upvotes: 6

Related Questions