title: How to Invert SVG text with appropriate kerning?
body: <p>How can I invert (rotate 180 degrees) a text object so that the text is kerned appropriately?</p>
  
  <p>My example uses Python and the svgwrite package, but my question seems about any SVG.</p>
  
  <p>Suppose I use the following code:</p>
  
  <pre><code>dwg = svgwrite.Drawing()
  dwg.add(dwg.text(fullName, (int(width/2.),gnameHeight), 
                      font_size=gnameFontSize, text_anchor="middle"))
  </code></pre>
  
  <p>The above code generates text looking like this:</p>
  
  <p><a href="https://i.stack.imgur.com/pvQYb.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pvQYb.png" alt="plain text"></a></p>
  
  <p><code>dwg.text()</code> objects accept a <code>rotate</code> parameter that is applied to all characters in a text string, so I've used the following code to reverse the string first:</p>
  
  <pre><code>pcRotate = [180]
  ngap = 1
  
  revFullName = fullName
  rcl = []
  for c in revFullName:
      rcl.append(c)
      for i in range(ngap):
          rcl.append(' ')
  
  rcl.reverse()
  revFullName = ''.join(rcl)
  
  dwg.add(dwg.text(revFullName, (int(width/2.),pcnameHeight), 
                  font_size=gnameFontSize, text_anchor="middle", rotate=pcRotate))
  </code></pre>
  
  <p>But, this produces the very ugly version below:</p>
  
  <p><a href="https://i.stack.imgur.com/irO5B.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/irO5B.png" alt="rotated text"></a></p>
  
  <p>and this is using an artificial space gap between characters to make it slightly less unreadable.</p>
  
  <p>What's the best way to tap into whatever kerning is being used by standard text in this inverted situation?</p>