2013-05-05 59 views
1

将自定义字体设置为HTML页面并使用loadDataWithBaseURL加载HTML数据时,粗体标记被忽略。我的代码是如下:Webview加载标签问题loadDataWithBaseURL

webView.loadDataWithBaseURL("", "<html><style type=\"text/css\"> @font-face { font-family:\"customFont\"; src:url('file:///android_asset/fonts/customfont.ttf');line-height:45px;font-size:34px;} body { font-family:'customFont'; }</style><body><b>The legend is back!!</b></body></html>", "text/html", "utf-8", ""); 

我的如下所示的输出:

当如下所示相同的内容使用loadData加载:

webView.loadData("", "<html><style type=\"text/css\"> @font-face { font-family:\"customFont\"; src:url('file:///android_asset/fonts/customfont.ttf');line-height:45px;font-size:34px;} body { font-family:'customFont'; }</style><body><b>The legend is back!!</b></body></html>", "text/html", "utf-8", ""); 

我的输出是如下所示:

enter image description here

不确定可能出现的问题。是否有任何具体原因相同。

+0

你有没有解决这个问题。即使我有同样的问题。 – amsiddh 2013-06-27 07:14:22

+0

尝试使用loadUrl方法,仍然是同样的问题。 – amsiddh 2013-06-27 11:33:22

回答

2

现在我通过使用粗体字体和使用css在我的html中指定相同的方法来解决此问题。我的css代码如下:

@font-face {font-family: MyArialBold;src: url('file:///android_asset/fonts/ArialBold.ttf')} b{font-family: ArialFontBold;}. 

希望有所帮助。

相关问题