Custom font for webview

后端 未结 6 588
伪装坚强ぢ
伪装坚强ぢ 2020-12-11 05:19

I am trying to establish a new custom font (otf file) for my web view.

I put anbaaarabic_bold.otf in assets file.

There is how i do:

String h         


        
6条回答
  •  情歌与酒
    2020-12-11 05:39

    I guess getActivity().getFilesDir().getAbsolutePath() doesn't get you into assets folder where your font resides, so the change of font is just ignored as it's not found When I was using custom fonts I used the path this.getAssets() + "your_font_name.otf"

    The code I used:

    Typeface type = Typeface.createFromAsset(this.getAssets(), fontName);
    ((TextView) findViewById(R.id.textView1)).setTypeface(type);
    

提交回复
热议问题