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

前端 未结 1 1454
隐瞒了意图╮
隐瞒了意图╮ 2021-01-20 22:34

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

相关标签:
1条回答
  • 2021-01-20 23:13

    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.

    0 讨论(0)
提交回复
热议问题