Custom font for webview

后端 未结 6 606
伪装坚强ぢ
伪装坚强ぢ 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:48

    There is a bug report for Android that seems to suggest that custom fonts don't work for certain languages (Thai, Hebrew, Farsi, and Arabic have been mentioned). This hasn't been confirmed by anyone from Google, but there are a number of people reporting the same problem.

    One of the suggested solutions (which at least one user confirmed as working) was to convert the font from otf to svg. There are a number of online tools that will do this for you (Everything Fonts is one example), but you may have issues with this being a copyrighted font - make sure your font license permits such conversions.

    Also, when you have converted the font, open it up in a text editor and check whether the svg element is namespaced. It should look something like this:

    
    

    If it is just without the namespace, you may need to add the xmlns attribute manually. Apparently, svg fonts without the namespace don't work either.

提交回复
热议问题