Problem
Having text in SVG is never easy. I found a few problems with text width calculation:



Possible Solution
There is an opentype.js library. It allows you to parse font files and do various manipulations with them. One of them is the calculation of the width of the text.
I propose to calculate the size of the text using this library and adjust the size of the elements.
Also! This may help to remove the <foreignObject /> hack.
Problem
Having text in SVG is never easy. I found a few problems with text width calculation:
Possible Solution
There is an opentype.js library. It allows you to parse font files and do various manipulations with them. One of them is the calculation of the width of the text.
I propose to calculate the size of the text using this library and adjust the size of the elements.
Also! This may help to remove the
<foreignObject />hack.