字体未嵌入webview中

时间:2014-05-26 07:47:51

标签: java android html css

我正在构建一个Android应用程序,我有一个webview,我试图在其中嵌入一个名为mylotus.ttf的assets文件夹中的字体。字体根本没有嵌入。

有任何帮助吗?

  webView.requestDisallowInterceptTouchEvent(true);
                         try
                         {
                         details_v=decipher(key, detailss_value);
                         }catch(Exception ex)
                         {}
                        yourHtml = "<html> " +
                                "<head><meta http-equiv='Content-Type' content='text/html; charset=utf-8'/></head>" +
                                "<style type=\"text/css\">" +
                                "@font-face {font-family: MyFont; src: url(\"file:///android_asset/fonts/mylotus.ttf\"); font-style: normal; font-weight: normal;}" +
                                "body{font-family: MyFont; color: #000000; background-color: #ffffff;}" +
                                ".Sec{direction:ltr; font-family: Times New Roman; font-weight:bold; font-size:x-large;}" +
                                ".Prim{color:#000000; direction:ltr;  font-family: MyFont; src: url(\"file:///android_asset/fonts/mylotus.ttf\"); font-weight:bold; font-size:x-large;}" +
                                ".Def_en{direction:ltr; font-family: MyFont; font-weight:Normal; font-size:x-large;}" +
                                ".Def_ar{direction:rtl; font-family: MyFont; font-size:x-large;}" +
                                ".smaller{direction:ltr; font-weight:Normal; font-family: MyFont; font-size:x-large;}" +
                                "</style>" +
                      "<body><table width = '100%' >" +
                                "<tr><td><h1><p align='left' ><font>"+keyword+"</font></p></h1></td></tr>" +
                                "<tr><td><p align='left' ><font>"+detailss_value+"</font></p></td></tr>" +
                                "</table></body></html>";

                        webView.loadDataWithBaseURL(null, yourHtml, "text/html", "UTF-8", null);

0 个答案:

没有答案
相关问题