我在我的应用程序中使用Webview,希望使用定制字体显示波斯语文本。我将我的字体放在asset文件夹中,并编写了一个在Webview中放置文本的方法。但在不支持波斯语的API 8中,它会显示未知字符,而在支持波斯语的API中,它不会使用自定义字体显示我的文本,而是使用默认字体显示。请问我的方法哪里有问题?谢谢。 我的方法:
public void setText(String text)
{
String style2="<style type=\"text/css\">@font-face {font-family: 'myface';src: url('file:///android_asset/BYekan.ttf'); } body {font-family: 'myface';}</style>";
this.loadDataWithBaseURL("file:///android_asset/BYekan.ttf","<html dir=\"rtl\"><head><meta content=\"text/html; charset=utf-8\" http-equiv=\"Content-Type\"/>"+style2+"</head><body>"+text+"</body></html>","text/html","UTF-8",null);
setClickable(false);
setLongClickable(false);
setFocusable(false);
setFocusableInTouchMode(false);
}