无法在 SVG 中将文本设为粗体

问题描述 投票:0回答:2
html css angular svg
2个回答
4
投票

正如我所评论的:在 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>
 
 


0
投票

font-weight="bold"
应该按照 MDN 文档工作。

请参阅 - https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/font-weight

这对我有用。

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.