Android 2.2 webview not supporting Tamil font

1k views Asked by At

i am developing new android application...i tried load html content in webview in 2.2 emulator but not supporting tamil font

here my code...

WebView learn2crack = (WebView)findViewById(R.id.webview);
learn2crack.getSettings().setDefaultTextEncodingName("utf-8");
learn2crack.getSettings().setJavaScriptEnabled(true);
learn2crack.loadUrl("http://www.dinamalar.com/");

thanks in advance

1

There are 1 answers

0
user3008032 On
Typeface tf = Typeface.createFromAsset(getAssets(), "Bamini.ttf");    
    String tamil_string="செய்திகள்";
    //creating intance of TamilFotnUtil Class
    TamilFontUtil tfUtil = new TamilFontUtil();

   //Convert Tamil font encording using the utility.
    String tamilStringEncoded =  tfUtil.convertTamilString(tamil_string);

add below line inside the the style

@font-face {font-family: MyCustomFont; src: url("Bamini.ttf")}body {font-family: MyCustomFont, Verdana, Arial, sans-serif; font-size: medium; color: black}"

for example

<html> <head>

 <title>example</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

 <style type="text/css">@font-face {font-family: MyCustomFont; src: 

url(file:///android_asset/Bamini.ttf)}body {font-family: MyCustomFont, Verdana, Arial, 

sans-serif; font-size: medium; color: black}</head><body>

<h1>tamilStringEncoded </h1></body></html>

finally load data into webview ....