SVG Scaling Text to fit container

If you really don’t care that the text gets ugly, here’s how to fit unknown length text into a known width.

<svg width="436" height="180"
    style="border:solid 6px"
    xmlns="http://www.w3.org/2000/svg">
    <g>
        <text y="50%" textLength="436" lengthAdjust="spacingAndGlyphs">UGLY TEXT</text>
    </g>
</svg>

enter image description here

Leave a Comment