58 android webview custom-font
现在我想显示一些unicode字符,我使用了tag : <font face="
Arial">something here</font>. 但似乎WebView找不到Arial字体,因为我只能看到UFO字符.我是否必须将arial.ttf复制到某处或者如何使用此TrueType字体WebView?谢谢.
小智 77
loadData也不适合我,所以我file:///android_asset在src路径中使用.
它合作loadDataWithBaseURL!
对于此示例,我将CSS更改为:
@font-face {
font-family: 'feast';
src: url('fonts/feasfbrg.ttf');
}
body {font-family: 'feast';}
Run Code Online (Sandbox Code Playgroud)
然后使用资源路径作为基本URL:
loadDataWithBaseURL("file:///android_asset/",myhtml,"text/html","utf-8",null);
Run Code Online (Sandbox Code Playgroud)
Zar*_*rah 34
显然,您可以使用自定义字体WebView,如上面建议的@raychung.但这不适用于2.1(此处报告了 Bug ).这适用于1.5,1.6和2.2.
您可以将自定义字体TTF文件放在您的/assets文件夹中,然后在您可以放入的CSS文件中:
@font-face {
font-family: "myIPA";
src: url('IPA.TTF');
}
.phon, .unicode
{
display: inline;
font-family: 'myIPA', Verdana, sans-serif;
font-size: 14pt;
font-weight: 500;
font-style:normal;
color: black;
}
Run Code Online (Sandbox Code Playgroud)
您现在可以在HTML文件中引用此字体样式.
| 归档时间: |
|
| 查看次数: |
60215 次 |
| 最近记录: |