【发布时间】:2019-06-18 15:47:33
【问题描述】:
我想将 Arial Bold 指定为 @font-face 规则中的后备字体。
像这样:
@font-face {font-family: myCustomFont; src: url(http://unreachableHost/font1b.ttf), local(Arial Bold)}
但它不起作用。至少在 Chrome 中没有。后备不是 Arial Bold 甚至不是 Arial Regular。
这是一个包含多个字体系列的示例。
@font-face {font-family: mustBeArialBold; src: url(http://unreachableHost/font1b.ttf), local(Arial Bold)}
@font-face {font-family: mustBeVerdanaBold; src: url(http://unreachableHost/font2b.ttf), local(Verdana Bold)}
@font-face {font-family: mustBeSegoeBold; src: url(http://unreachableHost/font3b.ttf), local(Segoe UI Bold)}
@font-face {font-family: mustBeTimesBold; src: url(http://unreachableHost/font4b.ttf), local(Times New Roman Bold)}
<body style="text-align: right">
<b style="font-family: Arial">This is Arial Bold</b> <br>
<c style="font-family: mustBeArialBold">This should be Arial Bold</c> <br><br>
<b style="font-family: Verdana">This is Verdana Bold</b> <br>
<c style="font-family: mustBeVerdanaBold">This should be Verdana Bold</c> <br><br>
<b style="font-family: Segoe UI">This is Segoe UI Bold</b> <br>
<c style="font-family: mustBeSegoeBold">This should be Segoe UI Bold</c> <br><br>
<b style="font-family: Times New Roman">This is Times New Roman Bold</b> <br>
<c style="font-family: mustBeTimesBold">This should be Times New Roman Bold</c> <br><br>
可以这样做吗?怎么样?
跟进:
这是@Kerri 建议的解决方案
@font-face {font-family: mustBeArial; src: local(Arial)}
@font-face {font-family: mustBeVerdana; src: local(Verdana)}
@font-face {font-family: mustBeSegoe; src: local(Segoe UI)}
@font-face {font-family: mustBeTimes; src: local(Times New Roman)}
<body style="text-align: right">
<b style="font-family: Arial">This is Arial Bold</b> <br>
<b style="font-family: mustBeArial">This should be Arial Bold</b> <br><br>
<b style="font-family: Verdana">This is Verdana Bold</b> <br>
<b style="font-family: mustBeVerdana">This should be Verdana Bold</b> <br><br>
<b style="font-family: Segoe UI">This is Segoe UI Bold</b> <br>
<b style="font-family: mustBeSegoe">This should be Segoe UI Bold</b> <br><br>
<b style="font-family: Times New Roman">This is Times New Roman Bold</b> <br>
<b style="font-family: mustBeTimes">This should be Times New Roman Bold</b> <br><br>
生成的文本看起来像粗体文本,但与真正的粗体字体完全不同。
【问题讨论】:
-
您可以尝试在您的
@font-face规则中包含font-weight: bold属性。请参阅MDN's documentation,尽管我相信这也会使您的非后备字体变粗。
标签: css fonts font-face fallback