将自定义字体设置为 html 页面并使用 loadDataWithBaseURL 加载 html 数据时,会忽略粗体标记。我的代码如下:
webView.loadDataWithBaseURL("", "<html><style type=\"text/css\"> @font-face { font-family:\"customFont\"; src:url('file:///android_asset/fonts/customfont.ttf');line-height:45px;font-size:34px;} body { font-family:'customFont'; }</style><body><b>The legend is back!!</b></body></html>", "text/html", "utf-8", "");
我的输出如下所示:
当使用 loadData 加载相同的内容时,如下所示:
webView.loadData("", "<html><style type=\"text/css\"> @font-face { font-family:\"customFont\"; src:url('file:///android_asset/fonts/customfont.ttf');line-height:45px;font-size:34px;} body { font-family:'customFont'; }</style><body><b>The legend is back!!</b></body></html>", "text/html", "utf-8", "");
我的输出如下所示:
不确定可能的问题是什么。有没有相同的具体原因。