正如我所评论的:在 SVG 中,您可以向文本添加笔划。这将使文本看起来像粗体。您可以根据需要使用笔画宽度将其设置为粗体。
text{stroke:black; stroke-width:.5}
<svg #speedAnimation class="speedAnimationClass" viewBox="-10 50 140 80" preserveAspectRatio="xMinYMax meet">
<text text-anchor="middle" x="60" y="100" >some text</text>
<text text-anchor="middle" x="60" y="120" class="speed-description">speed Description</text>
</svg>
您也可以使用
<feMorphology>
来实现此目的。在这种情况下,您需要使用 <feMorphology>
的半径属性值
<svg #speedAnimation class="speedAnimationClass" viewBox="-10 50 140 80" preserveAspectRatio="xMinYMax meet">
<filter id="dilate">
<feMorphology operator="dilate" radius=".5"/>
</filter>
<text text-anchor="middle" x="60" y="100" filter="url(#dilate)" >some text</text>
<text text-anchor="middle" x="60" y="120" class="speed-description" filter="url(#dilate)">speed Description</text>
</svg>
font-weight="bold"
应该按照 MDN 文档工作。
请参阅 - https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/font-weight
这对我有用。