gpt4 book ai didi

android - Android 应用程序中静态 html 中的自定义字体

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

我有一个 fragment ,其中有一个 webview,我从 assets 文件夹中加载了静态 HTML。我想将 Roboto 和 Roboto Light 的组合用于此 html 中的字体。我应该怎么做?

我已经从 Google Fonts 下载了 Roboto 字体,但我不知道将它们放在哪里或如何引用它们。我希望它可以离线工作。

最佳答案

我建议您为此使用 CSS。为 html 文件创建 CSS 样式并在其中使用此代码。

CSS 文件中。

@font-face {
font-family: 'font';
src: url('fonts/font.ttf');
}

html

<div class="body" >

your doucumention

</div>

CSS

.body{

font-family:font;

}

在 html 文件中使用这个内部 head 标签将其与 css 链接。

<link rel="stylesheet" href="yourcss.css" type="text/css" /> 

希望对你有用。

关于android - Android 应用程序中静态 html 中的自定义字体,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24941460/

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