Although I'm not that experienced with javascript
, I find myself in a position where I need to use it.
What I am trying to achieve is changing the font of the webView
in Android after the web page has finished loading.
So, within the onPageFinished()
method, I execute some javascript
code.
I have successfully changed the font using this code:
loadurl("javascript:(function(){document.body.style.fontFamily='\"Courier New\", Courier, monospace';})()");
However, my goal is to apply a custom font from an asset instead.
I attempted something like this:
loadurl("javascript:(function(){document.body.style.fontFamily= \"src: url('file:///android_asset/byekan.ttf')\";})()");
And tried similar approaches, but without any luck.
If anyone can assist me in applying my own custom font after loading a page in an Android webview, I would greatly appreciate it.
Note: The HTML content is sourced externally (not local), so I am unable to add any CSS styles directly to it.