问题
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