PARKA
PARKA

Reputation: 49

SVG textpath issues

I'm working on SVG elements and I've added a textpath on a path. Just like on this link.

https://developer.mozilla.org/en/docs/Web/SVG/Element/textPath

But I need to add the text on two lines separated like with a 'br'.

enter image description here

Did someone know how to do that, Best regards,

Upvotes: 2

Views: 612

Answers (1)

Access Denied
Access Denied

Reputation: 9491

Use dy in em units:

<svg width="100%" height="100%" viewBox="0 0 1000 300"
     xmlns="http://www.w3.org/2000/svg" 
     xmlns:xlink="http://www.w3.org/1999/xlink">
  <defs>
    <path id="MyPath"
          d="M 100 200 
             C 200 100 300   0 400 100
             C 500 200 600 300 700 200
             C 800 100 900 100 900 100" />    
  </defs>

  <use xlink:href="#MyPath" fill="none" stroke="red"  />

  <text font-family="Verdana" font-size="42.5" dy="-1em">

<textPath xlink:href="#MyPath">
      We go up, then we go down, then up again
    </textPath>

  </text>
<text dy="0em" font-family="Verdana" font-size="42.5">

<textPath xlink:href="#MyPath">
      SecondLine
    </textPath>

  </text>

  <!-- Show outline of the viewport using 'rect' element -->
  <rect x="1" y="1" width="998" height="298"
        fill="none" stroke="black" stroke-width="2" />
</svg>

Upvotes: 1

Related Questions