title: Change font WebView for an already loaded site with Android
body: <p>I have been searching for days but could not find solution for my problem. Please kindly take a look:</p>
  
  <ul>
  <li>Input: a WebView with an already loaded web.</li>
  <li>Output: change the font of that loaded web inside the WebView.</li>
  </ul>
  
  <p>What I have done so far is this:</p>
  
  <pre><code>    @SuppressLint("SetJavaScriptEnabled")
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
  
      mWebView = (WebView) findViewById(R.id.webview);
      mWebView.getSettings().setJavaScriptEnabled(true);
      mWebView.setWebViewClient(new WebViewClient());
      mWebView.loadUrl("http://www.bbc.co.uk/");
  </code></pre>
  
  <p>and then, this is how I change the font inside webview:
  1/ way 1:</p>
  
  <pre><code>        mWebView.loadUrl("javascript:(function() { var s=document.createElement('style');s.innerHTML ="
              + " '@font-face{font-family:ZawGyi-One;src:url(\"http://db.tt/OQ1RZoWc\");}"
              + "body,div,h1,h2,h3,input,textarea{font-family:ZawGyi-One! important;}';"
              + "document.getElementsByTagName('head')[0].appendChild(s);document.getElementsByTagName('body')[0].style.fontFamily = \"ZawGyi-One\"})()");
  </code></pre>
  
  <p>2/ way 2: </p>
  
  <pre><code>mWebView.loadDataWithBaseURL(
              null,
              "&lt;script&gt;javascript:(function() { var s=document.createElement('style');s.innerHTML ="
                      + " '@font-face{font-family:ZawGyi-One;src:url(\"http://db.tt/OQ1RZoWc\");}"
                      + "body,div,h1,h2,h3,input,textarea{font-family:ZawGyi-One! important;}';"
                      + "document.getElementsByTagName('head')[0].appendChild(s);document.getElementsByTagName('body')[0].style.fontFamily = \"ZawGyi-One\"})() &lt;/script&gt;",
              "text/html", "UTF-8", null);
  </code></pre>
  
  <p>3/ way 3:</p>
  
  <pre><code>        mWebView.setWebViewClient(new WebViewClient() {
          @Override
          public void onPageFinished(WebView view, String url) {
              // TODO Auto-generated method stub
              super.onPageFinished(view, url);
  
              mWebView.loadUrl("javascript:(function() { var s=document.createElement('style');s.innerHTML ="
                      + " '@font-face{font-family:ZawGyi-One;src:url('file:///android_asset/fonts/BLKCHCRY.TTF');}"
                      + "body,div,h1,h2,h3,input,textarea{font-family:ZawGyi-One! important;}';"
                      + "document.getElementsByTagName('head')[0].appendChild(s);document.getElementsByTagName('body')[0].style.fontFamily = \"ZawGyi-One\"})()");
  
          }
      });
  </code></pre>
  
  <p>But unfortunately, none of my solutions works. Even though I have tried to change html file insdie /assets/ folder and also the fonts are stored at /assets/fonts/ folder, I cannot walk through this.</p>
  
  <p>**One more question: is it really possible to change font style inside an already loaded site of webview ? Someone, please kindly guide me.</p>
  
  <p>I am appreciated your great help.</p>