Android font change not working

I use the following line of code to change the font type in an android application: L

 Typeface font = Typeface.createFromAsset(this.getAssets(), "fonts/Abumohammed.ttf"); textView.setTypeface(font); 

I am sure that Abumohammed.ttf is located in the assets/fonts folder .. but the font does not change and does not affect the text image !!

+4
source share
2 answers

Android does not support every font file. When it fails, it tends to fail, showing the default font instead. I have no idea what Android is not like in some of them.

I would find some font that definitely works, such as this one , and try to make sure the rest of your code is in order. If you really determine that the font file is not working, AFAIK you have no choice but to find another font.

+3
source

I was annoyed enough that I thought I would share some of the results of my digging. I tried several font files that ended up using a fallback font. To “fix” some of these files, I just had to open the file in FontForge, then File-> Generate Font and save it again as TTF. This allowed some who were not shown to draw correctly.

Others required moving glyphs from the Microsoft area (U + F030) to the U + 0030 range.

I did not educate myself on what Generate Font actually does. But now that I know HOW to fix it, I can at least start figuring out why it does not work. I suspect that this can only be fixed in the AOSP tree.

+2
source

All Articles