简体   繁体   English

SVG tspan元素+字体家族样式?

[英]SVG tspan element + font-family style?

I am trying to specify the font family inside of a tspan element within an svg button. 我正在尝试在svg按钮内的tspan元素内指定字体系列。 It doesn't seem to register and I have not been able to find any documentation on this. 它似乎没有注册,而且我还没有找到任何文档。 I have only found documentation for the text element inside of an svg. 我只在svg中找到有关text元素的文档。 My numerous attempts have not resulted in the text matching the style of the rest of the site. 我的大量尝试都没有使文本与网站其余部分的样式匹配。 I need it to use the thin version of the Raleway font from Google. 我需要它来使用Google的Raleway字体的精简版本。

HTML HTML

<svg viewbox="0 0 86 20" version="1.1" baseProfile="full" width="200" height="200" xmlns="http://www.w3.org/2000/svg">
  <g>
    <path id="thisID" d="M 80 5 A 100 100 0 0 0 22.2 27.2 L 37.58 42.58 A 80 80 0 0 1 80 27.2 Z"></path>
    <text font-family:"Raleway:thin" fill="gold">
        <defs>
    <style type="text/css">@import url('https://fonts.googleapis.com/css?family=Raleway:thin');</style>
</defs>
         <textPath style="font-size:6pt;" xlink:href="#thisID" startOffset="63%" >
            <tspan dy="-6">Home</tspan>
      </textPath>
    </text>
  </g>
</svg>

A NEW ATTEMPT 新尝试

Hm, I attempted to use the method below without success. 嗯,我尝试使用下面的方法没有成功。 What am I missing here? 我在这里想念什么?

<svg viewbox="0 0 86 20" version="1.1" baseProfile="full" width="200" height="200" xmlns="http://www.w3.org/2000/svg">
          <style type="text/css">
        <![CDATA[   

  @import url('https://fonts.googleapis.com/css?family=Raleway:thin');
              {font-family:Raleway}

             ]]> 
  </style>
  <g>
    <path onclick="window.location='index.html';" id="thisID" d="M 80 5 A 100 100 0 0 0 22.2 27.2 L 37.58 42.58 A 80 80 0 0 1 80 27.2 Z"></path>
    <text font-family:"Raleway:thin" fill="gold">
         <textPath style="font-size:6pt;" xlink:href="#thisID" startOffset="63%" >
            <tspan dy="-6">Home</tspan>
      </textPath>
    </text>
  </g>
</svg>

You forgot to declare the font-family. 您忘记声明字体系列了。

 <svg viewbox="0 0 86 20" version="1.1" baseProfile="full" width="200" height="200" xmlns="http://www.w3.org/2000/svg"> <style type="text/css"> <![CDATA[ @import url('https://fonts.googleapis.com/css?family=Raleway:thin'); text{font-family:Raleway} ]]> </style> <g> <path id="thisID" d="M 80 5 A 100 100 0 0 0 22.2 27.2 L 37.58 42.58 A 80 80 0 0 1 80 27.2 Z"></path> <text font-family:"Raleway:thin" fill="gold"> <textPath style="font-size:6pt;" xlink:href="#thisID" startOffset="63%" > <tspan dy="-6">Home</tspan> </textPath> </text> </g> </svg> 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM