Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/ant/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android webView中的阿拉伯语自定义字体_Android_Webview_Fonts - Fatal编程技术网

Android webView中的阿拉伯语自定义字体

Android webView中的阿拉伯语自定义字体,android,webview,fonts,Android,Webview,Fonts,我正在尝试将阿拉伯语自定义字体添加到webView,但运气不好。在我的例子中,webView呈现设备附带的默认字体 我曾经尝试过ttf和otf字体类型,但也没有成功地将字体类型转换为svg 这是我的密码: 存储在资产文件夹中的html文件: <html> <head> <meta http-equiv="content-type" content="text/html;" charset="UTF-8"> <style>

我正在尝试将阿拉伯语自定义字体添加到webView,但运气不好。在我的例子中,webView呈现设备附带的默认字体

我曾经尝试过ttf和otf字体类型,但也没有成功地将字体类型转换为svg

这是我的密码:

存储在资产文件夹中的html文件:

 <html>
<head>
    <meta http-equiv="content-type" content="text/html;" charset="UTF-8">
    <style>
        /** Specify a font named "MyFont",
        and specify the URL where it can be found: */
        @font-face {
        font-family: "MyFont";
        src: url('file:///android_asset/fonts/NotoKufiArabic-Bold.ttf') format(‘truetype’); ;
        }
        h3 { font-family:"MyFont"}
    </style>
</head>
<body>
<h3>
مرحبا</h3>
</body>
</html>
对于英文文本和字体,我的代码可以正常工作,但对于阿拉伯文,我的代码不能正常工作。

使用
阿拉伯文文本

  • dir=“rtl”
    通知文本为阿拉伯文本
  • lang=“ar”
    从右向左渲染表单
 public class MainActivity extends Activity {

    WebView mWebView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        // Getting reference to WebView of the activity_main layout
        mWebView = (WebView) findViewById(R.id.webview);

        // Loading an html page into webview
        mWebView.loadUrl("file:///android_asset/demo.html");
    }
 ...........
 ...........