In [1]:
import cairosvg
from IPython.display import SVG, Image, HTML
In [2]:
def show(text_content, text_attributes=""):
    svg = f"""
        <svg width="500" height="80" xmlns="http://www.w3.org/2000/svg">
        <rect x="0" y="0" width="500" height="80" fill="lightgrey"/>
        <circle cx="250" cy="40" r="5" fill="green"/>
        <text x="250" y="40" font-size="32px" {text_attributes}>{text_content}</text>
        </svg>
    """.format()
    
    print("cairosvg.svg2png(...)")
    cairosvg.svg2png(svg, write_to='test.png')
    display(Image("test.png"))

    print("IPython.display(SVG(...))")
    display(SVG(svg))
In [3]:
show(
    text_content = """<tspan>1.000·</tspan><tspan>10</tspan><tspan dy="-0.6em" font-size="0.6em">-12</tspan>""", 
    text_attributes='text-anchor="middle"'
)
cairosvg.svg2png(...)
IPython.display(SVG(...))
1.000·10-12

Doesn't work even with tspans that don't have any style

In [4]:
show(
    text_content = """<tspan>one</tspan><tspan>TWO</tspan><tspan>three</tspan>""", 
    text_attributes='text-anchor="middle"'
)
cairosvg.svg2png(...)
IPython.display(SVG(...))
oneTWOthree

For single tspan text-anchor works as expected

In [5]:
show(
    text_content="""<tspan>oneTWOthree</tspan>""", 
    text_attributes='text-anchor="middle"'
)
cairosvg.svg2png(...)
IPython.display(SVG(...))
oneTWOthree