Search code examples
androidwebviewfontsassets

what is the address of a font in assets folder - android studio


I have a webView in my app and I need to set the font-family from a .ttf font which is inside the assets folder, here is my String which fills the 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>";

My question is how I can refer to that .ttf font in my font_family variable in order to change the WebView font?


Solution

  • the address of a file in app:\src\main\assest is "file:///android_asset/a.ttf" in android studio