如何使用自定义字体与web视图自定义、视图、如何使用、字体

2023-09-11 12:00:29 作者:装逼是挨揍的前兆╮

现在我想展示一些UNI code字符,我已经使用的标签:<字型= 宋体>此处的东西与LT; / FONT> 但似乎的WebView 找不到宋体 字体是因为我只能看到不明飞行物字符。我一定要复制arial.ttf到 什么地方,或者我该如何使用这个TrueType字体与的WebView ?谢谢你。

Now I want to display some unicode characters and I have used tag: <font face=" Arial">something here</font>. But it seems that WebView can not find the Arial font because I can only see UFO-characters. Do I have to copy arial.ttf to somewhere or how can I use this TrueType font with WebView? Thanks.

推荐答案

loadData 对我也没有工作,所以我用文件: /// android_asset在src路径

loadData didn't work for me either, so I used file:///android_asset in the src path.

据曾与 loadDataWithBaseURL

在这个例子中我改变了CSS来:

For this example I changed the CSS to:

@font-face {
    font-family: 'feast';
    src: url('fonts/feasfbrg.ttf');
}

body {font-family: 'feast';}

然后使用资产路径为基准网址:

Then use the assets path as the base url:

loadDataWithBaseURL("file:///android_asset/",myhtml,"text/html","utf-8",null);