我在webview上使用了这个字体
String data = "<!DOCTYPE html>";
data +="<head>\n" +
"<style type=\"text/css\">\n" +
"@font-face {\n" +
" font-family: MyFont;\n" +
" src: url(\'file:///android_asset/fonts/MyFont.otf\')\n" +
"}\n" +
"body {\n" +
" font-family: MyFont;\n" +
" font-size: medium;\n" +
" text-align: justify;\n" +
"}\n" +
"</style>\n" +
"</head>";
data += "<body dir=\"rtl\" style=\"text-align:justify\">";
data += "my text";
data +="</body></html>";
// args: data, mimeType, encoding
web1.loadData(`data, "text/html", null);
但它不适合我的字体。非常感谢
答案 0 :(得分:0)
您需要指定file:///android_asset
作为数据的基本网址:URI:
web1.loadDataWithBaseURL("file:///android_asset/", data, "text/html", "utf-8", null);