So I have this HTML/CSS snippet:
<text class="amount" >500</text>
You can't do this automatically. SVG does not have automatic layout like HTML. You have to set its width and height, similar to the
getBBox() on the text element) and altering the size of the SVG to match.