Le texte peut-il être ajouté à un chemin SVG?

Est-il possible d'ajouter du texte à un chemin svg, j'ai créé un triangle svg et je voudrais ajouter une lettre au centre de ceci mais je ne sais pas si cela est possible?

Oui. Voir la section 10.13 de la spécification SVG1.1 (intitulée "Texte sur un chemin d'accès") pour plus d'informations sur l'utilisation de l'élément textPath .

Résumé:

  1. Donnez votre chemin à un attribut id .
  2. Créer <textPath xlink:href="#pathid">My text here</textPath>

Voici un exemple directement de la spécification:
http://www.w3.org/TR/SVG/images/text/toap01.svg

 <?xml version="1.0" standalone="no"?> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> <svg width="12cm" height="3.6cm" viewBox="0 0 1000 300" version="1.1" 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> <desc>Example toap01 - simple text on a path</desc> <use xlink:href="#MyPath" fill="none" stroke="red" /> <text font-family="Verdana" font-size="42.5" fill="blue" > <textPath xlink:href="#MyPath"> We go up, then we go down, then up again </textPath> </text> </svg>