我想在
像这样:
@font-face
规则中指定Arial Bold作为回退字体。像这样:
@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文档,但我认为这也会使你的非回退字体变粗。 - Heretic Monkey