Android 2.2 webview 不支持泰米尔语字体

标签 android utf-8 android-webview tamil

我正在开发新的 android 应用程序...我尝试在 2.2 模拟器的 webview 中加载 html 内容,但不支持泰米尔字体

这里是我的代码...

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

提前致谢

最佳答案

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);

在样式中添加下一行

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

例如

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

最后加载数据到webview....

关于Android 2.2 webview 不支持泰米尔语字体,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20422043/

相关文章:

r - ggplot2 PDF 输出中的 Unicode 字符

c# - C++ 在 Visual Studio 2010 中从二进制文件读取 void* 数据作为 utf8

android - setAllowUniversalAccessFromFileURLs?

javascript - 从 native 应用程序访问 WebSQL

android - 如何以编程方式在 SD 卡上创建新目录?

android - Android 中电子邮件的自定义标题?

java - 二维码扫描仪无法在 android 6.0.1 中运行(显示白屏)

python - Unicode解码错误: 'gbk' codec can't decode byte when read json contains chinese

Android WebView在某些手机上无法显示html表格的右边框

android - Webview 没有完成加载