我需要在 webView Html 页面中使用 UhmanicHafs.ttf 字体来获得预期的输出。
我正在设置 uthmanic 字体
:
webviewHTML.loadDataWithBaseURL("file:///android_asset/fonts/UthmanicHafs.ttf",
myHtmlString, "text/html", Xml.Encoding.UTF_8.toString(), null);
然后我得到 Actual Output
如果我像这样删除 UthmanicHafs.ttf
字体:
webviewHTML.loadDataWithBaseURL("file:///android_asset/", myHtmlString, "text/html", Xml.Encoding.UTF_8.toString(), null);
我得到这个 Expected Output
我需要什么:
我需要使用 Uthmanic 字体并获得预期的输出。任何人都可以提供帮助。谢谢。
最佳答案
你需要在你的css文件中设置如下自定义字体
对于此示例,将 CSS 写入:
@font-face {
font-family: 'feast';
src: url('fonts/yourfont.ttf');
}
body {font-family: 'feast';}
Then use the assets path as the base url:
loadDataWithBaseURL("file:///android_asset/",myhtml,"text/html","utf-8",null);
那么它应该可以正常工作。
关于android - 在 WebView html 问题中设置字体样式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28689559/