Android 2.2 webview not supporting Tamil font

柔情痞子 提交于 2019-12-24 17:10:04

问题


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:


Try this link

Tamil fonts in Android

https://github.com/mayooresan/Japs-Attack-Ceylon--Android-App




回答2:


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 ....



来源:https://stackoverflow.com/questions/20422043/android-2-2-webview-not-supporting-tamil-font

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!