XML technologies / SVG / Using text elements / Solutions

(Excerpt from “Das Einsteigerseminar SVG — Webgrafiken mit XML” by Helma Spona)

  1. To specify the character encoding, use the encoding attribute in the SVG file’s first element.

<?xml version="1.0" encoding="iso-8859-1" ?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20001102//EN" "http://www.w3.org/TR/2000/CR-SVG-20001102/DTD/svg-20001102.dtd">
<svg>
  ...
</svg>

  1. To insert text, again use the <text> tag.

<text x="0" y="20">Texte können auch an Pfaden ausgerichtet werden!</text>

  1. Use the following instruction to create the path:

  2. <path d="M0 0 l+300 +300"/>
  3. Name the path and align the text with it using the <textPath> tag and its attribute xlink:href:

<text x="0" y="20">
  <textPath xlink:href="#linie">Texte können auch an Pfaden ausgerichtet werden!</textPath>
</text>
<path id="linie" d="M0 0 l+300 +300" />

  1. For spaced text, add to the <text> tag the style attribute as shown: <text x="0" y="20" style="letter-spacing:4">.

   

 

 

 

back to top