gpt4 book ai didi

android - Webview 粗体标记问题与 loadDataWithBaseURL

转载 作者:行者123 更新时间:2023-11-29 21:43:48 26 4
gpt4 key购买 nike

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

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

不确定可能的问题是什么。是否有任何特定原因。

最佳答案

现在我通过使用粗体字体并在我的 html 中使用 css 指定相同的字体来解决这个问题。我的 CSS 代码如下:

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

希望对您有所帮助。

关于android - Webview 粗体标记问题与 loadDataWithBaseURL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16386040/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com