Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Custom Font Issue In Android

Tags:

android

I am trying to use custom font in android. I have written java code as given below.

TextView txt = (TextView) findViewById(R.id.customfont);
Typeface font = Typeface.createFromAsset(getAssets(), "fonts/Molot.otf");
txt.setTypeface(font);

where I have stored the custom font in "./assets/fonts/" folder.

But, I am getting nullpointerexception on the 3rd line.

Can anybody give me the solution for this issue? Thanks

like image 467
RATTLESNAKE Avatar asked Sep 09 '10 07:09

RATTLESNAKE


People also ask

How do I fix my font on my Android?

To change the font, go to Settings > Display > Font size and style. Select your desired font in Font style to set it as the system font. On a OnePlus device, go to Settings > Personalisations > Font & display size.

How do I get custom fonts on my Android?

To install a custom font on Android, obtain the TTF file of the font you wish to use and also download the zFont app. Use the zFont app to install the TTF. It may require some prerequisites and the app will help you do it.


1 Answers

Android supports only TTF font type not OTF. Check this link

"RuntimeException: native typeface cannot be made" when loading font

like image 70
DeRagan Avatar answered Nov 10 '22 00:11

DeRagan