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
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.
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.
Android supports only TTF
font type not OTF
. Check this link
"RuntimeException: native typeface cannot be made" when loading font
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With