我的应用程序中有一个webview,我需要从assets文件夹中的.ttf字体设置字体系列,下面是填充webview的字符串:
String font_size = 24;
String font_family;
String main_txt = "<html>" + "<head></head>" + "<body dir='rtl' style='font-size: " +font_size+"px; 'font-family: "+font_family+";"+">" + "<text-align: justify;' >" + book.get("content").toString() + "</body>" + "</html>";
我的问题是如何在FONT_族变量中引用.ttf字体以更改Webview字体?
最佳答案
如果您将字体引用为fonts/mytypeface.ttf
,则它可以用于任何assets/fonts/*
文件。
// Font must be placed in assets/fonts folder
@font-face {
font-family: spqr; src: url('fonts/spqr.ttf');
}
关于android - Assets 文件夹中的字体的地址是什么-android studio,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/51927100/