How to Invert SVG text with appropriate kerning?
<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.  suppose using 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>generates some text looking like this:</p>

<p><a href="http://i.stack.imgur.com/pvQYb.png" rel="nofollow"><img src="http://i.stack.imgur.com/pvQYb.png" alt="enter image description here"></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 coded 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="http://i.stack.imgur.com/irO5B.png" rel="nofollow"><img src="http://i.stack.imgur.com/irO5B.png" alt="enter image description here"></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>

<p>The <code>rotate</code> attribute of a <code>&lt;text&gt;</code> element is intended for situations where you want to rotate individual characters.  If you want to rotate the whole text object then you should be using a <code>transform</code> instead.</p>

<p><a href="http://pythonhosted.org/svgwrite/classes/mixins.html#transform-mixin" rel="nofollow">http://pythonhosted.org/svgwrite/classes/mixins.html#transform-mixin</a></p>

python svg svgwrite