有没有办法将字体添加到资产文件夹并为 html 加载它?
is there a way to add a font into assets folder and load it for html?
我希望我的文字在 中看起来更好,但是当我尝试为其加载字体时,它并没有改变。
根据一些问题 and this 我找到了这段代码:
<style type="text/css">
@font-face {
font-family: "My Custom Font";
src: url(http://www.example.org/mycustomfont.ttf) format("truetype");
}
p.customfont {
font-family: "My Custom Font", Verdana, Tahoma;
}
</style>
<p class="customfont">Hello world!</p>
我试过从资产加载它:
<style type=text/css>
@font-face {
font-family: "ROYA";
src="Roya.ttf";
}
p.customfont {
font-family: "ROYA", Verdana, Tahoma;
}
<p class="ROYA">Hello world!</p>
但它不起作用。我该怎么办?
你还需要url()
。
@font-face{
font-family: "ROYA";
src: url("Roya.ttf") format("truetype")
}
使用 : 或 =
@font-face{
font-family: "ROYA";
src: url("Roya.ttf") format("truetype");
}
并在下一个代码块上更改 class 名称
p.ROYA {
font-family: "ROYA", Verdana, Tahoma;
}
<p class="ROYA">Hello world!</p>
我希望我的文字在
<style type="text/css">
@font-face {
font-family: "My Custom Font";
src: url(http://www.example.org/mycustomfont.ttf) format("truetype");
}
p.customfont {
font-family: "My Custom Font", Verdana, Tahoma;
}
</style>
<p class="customfont">Hello world!</p>
我试过从资产加载它:
<style type=text/css>
@font-face {
font-family: "ROYA";
src="Roya.ttf";
}
p.customfont {
font-family: "ROYA", Verdana, Tahoma;
}
<p class="ROYA">Hello world!</p>
但它不起作用。我该怎么办?
你还需要url()
。
@font-face{
font-family: "ROYA";
src: url("Roya.ttf") format("truetype")
}
使用 : 或 =
@font-face{
font-family: "ROYA";
src: url("Roya.ttf") format("truetype");
}
并在下一个代码块上更改 class 名称
p.ROYA {
font-family: "ROYA", Verdana, Tahoma;
}
<p class="ROYA">Hello world!</p>