I am trying to create an svg with one single text element. The size of the svg should be determined solely by the font size of the text, and it should fit the text perfectly. The closest I have come to what I am looking for is this:
txt_img = Vips::Image.svgload_buffer %(
<svg height="#{font_size}*2">
<g>
<text
font-family="some value"
font-size="#{font_size}"
font-weight="some value"
fill="some value"
fill-opacity="some value"
stroke="some value"
stroke-width="some value"
dominant-baseline="hanging"
text-anchor="start"
x="0"
y="#{font_size}"
>
#{txt}
</text>
</g>
</svg>
)
But, as you can see in the attached image, the bottom of the text gets cut off, particularly the letters that hang below the baseline. How can I size the svg to perfectly fit the text? Since this is not being rendered in a browser environment, the solution must not involve css.
Also note that the output is being rendered with Vips, which does not offer an svg saver option, which is why the output is in png format.
[!][text rendered to png][1]][1] [1]: https://i.stack.imgur.com/Bx7gJ.png