PhoneGap自定义语言设置

时间:2015-04-01 08:21:46

标签: android css cordova phonegap-build

我尝试过很多例子,其中没有一个是工作。这就是我想做的事情。我有一个phonegap eclipse项目。项目结构是

enter image description here

我想为我的项目添加自定义语言。这是我的MainActivity.java

import org.apache.cordova.DroidGap;

import android.os.Bundle;

public class MainActivity extends DroidGap {


@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
        super.loadUrl("file:///android_asset/www/index.html");

 }
}

这是我的index.html

 <!DOCTYPE html>
 <html>
  <head>
  <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-   scale=1, minimum-scale=1, width=device-width;" />
  <title>Directory Reader</title>
  <link rel="stylesheet" href="jquery/jquery.mobile-1.1.1.min.css" />
  <script src="jquery/jquery-1.8.0.min.js"></script>
  <script src="jquery/jquery.mobile-1.1.1.min.js"></script>
    <script type="text/javascript" src="cordova-2.0.0.js"></script>

  <style type="text/css">
  @font-face {
   font-family: MyCustomFont;
   src: url("NotoSansSinhala-Regular.eot") /* EOT file for IE */
  }
   @font-face {
   font-family: MyCustomFont;
   src: url("NotoSansSinhala-Regular.ttf") /* TTF file for CSS3 browsers */
  }

  body {
  font-family: MyCustomFont, Verdana, Arial, sans-serif;
  font-size: medium;
  color: black
  }
  </style>


 </head>
 <body>

 <p> test goda </p>
 </div>
 </body>
 </html>

我要显示的字体仍未显示在移动设备上。显示英文字符&#34;测试goda&#34;。任何想法如何解决这个问题?

1 个答案:

答案 0 :(得分:1)

您基本上需要root设备才能在Android 4.4上安装Sinhala文本,但它适用于Android 5.0 +

您基本上需要以下步骤:

  1. 将字体文件复制到/ system / fonts
  2. 从/ etc
  3. 下载fallback_fonts.xml文件
  4. 打开fallback_fonts.xml文件并通过添加字体进行修改 名称。将文件复制回/ etc目录。
  5. 更改fallback_fonts.xml文件和字体的权限 文件到644或-rw-r-r -
  6. 请参阅屏幕截图here

    的阅读说明