Custom Font Issue In Android
I am trying to use开发者_StackOverflow中文版 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
Android supports only TTF
font type not OTF
. Check this link
"RuntimeException: native typeface cannot be made" when loading font
Android supports OTF as well. Your font may be corrupt.
Download delicious font from www.exljbris.com/delicious.html. It is an otf font and it works for me.
Try this
Typeface font = Typeface.createFromAsset(getAssets(), "/fonts/Molot.otf");
精彩评论