title: Add custom font for android webview
body: <p>I want to develop a simple android web browser app that support a Unicode font I provide. I did some research but I couldn't find a successful method to add a custom font for a android <code>WebView</code>. There are some solutions to add custom fonts for a <code>WebView</code> but they are all based on adding font in the <code>CSS</code>. but since I don't have control over the page I load inside the WebView is there a method to add a font directly to the <code>WebView</code> like <code>setTypaFace()</code> method for <code>TextView</code>.?  </p>
  
  <p>here is the code i have used so far to add custom font for webview:</p>
  
  <pre><code>package com.example.sinhalafontrendering;
  
  import android.app.Activity;
  import android.graphics.Typeface;
  import android.os.Bundle;
  import android.view.Menu;
  import android.webkit.WebView;
  import android.widget.TextView;
  
  import com.example.sinhalafontrendering.R.id;
  
  public class MainActivity extends Activity {
      WebView mWebView;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
          FontUtils.setCustomFont(findViewById(id.txtHelloWorld), getAssets());
          Typeface tf = Typeface.createFromAsset(getAssets(), "iskpota.ttf");
          TextView tv = (TextView) findViewById(id.txtHelloWorld);
          tv.setText("ශ්‍රී ලංකා, \n ");
          //tv.setTypeface(tf,0);
  
          String html = "&lt;html&gt;&lt;head&gt;&lt;style type=\"text/css\"&gt;@font-face { font-family: MyCustomFont; src: url(\"Bamini.eot\") /* EOT file for IE */}@font-face { font-family: MyCustomFont; src: url(\"file:///android_asset/iskpota.ttf\") /* TTF file for CSS3 browsers */}body { font-family: MyCustomFont, Verdana, Arial, sans-serif;font-size: medium;color: black}&lt;/style&gt;&lt;/head&gt;&lt;body&gt;&lt;LI&gt;&lt;a href=\"http://www.thelastrow.lk/\"&gt;ශ්‍රී ලංකා;&lt;/a&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/div&gt;&lt;/body&gt;&lt;/html&gt;";
  
          mWebView = (WebView) findViewById(R.id.webGoogle);
          mWebView.getSettings().setJavaScriptEnabled(true);
          mWebView.getSettings().setBuiltInZoomControls(true);
          mWebView.getSettings().setSupportZoom(true);
          //mWebView.loadUrl("file:///android_asset/a.html");
          mWebView.loadDataWithBaseURL("www.thelastrow.lk", html, "text/html", "UTF-8", null);
          mWebView.setWebViewClient(new HelloWebViewClient());
  
  
      }
  
      @Override
      public boolean onCreateOptionsMenu(Menu menu) {
          // Inflate the menu; this adds items to the action bar if it is present.
          getMenuInflater().inflate(R.menu.main, menu);
          return true;
      }
  }
  </code></pre>