I want to change font face of html string loaded into WebView similarly as mentioned in this question:
How to change font face of Webview in Android?
The dif
I managed to load my local font from res/font directory. In my example i want to load italic opensans.
My setup are as follow:
assets directory @font-face {
font-family: 'opensans';
src: url("file:///android_res/font/opensans_italic.ttf")
}
body {
font-family: 'opensans';
font-weight: 400;
}
Load the WebView using loadDataWithBaseUrl, for example:
webView.loadDataWithBaseURL(null, yourHtmlContent, "text/html", "utf-8", null)
But i have this at the the top of my html content:
"”
I hope it works too for your case.
Edit:
Add this in your proguard config to make it work in release mode.
-keep class com.your.package.name.R$font { *; }