var svgHelper = svgHelper || {}; svgHelper.CalculateTextBlockDimensions = function (textParams) { const svg = ` ${textParams.Text} `; const el = document.createElement("div"); el.innerHTML = svg; document.body.appendChild(el); const svgText = el.querySelector('text').getBBox(); el.remove(); const result = { Height: Math.round(svgText.height), Width: Math.round(svgText.width) }; return result; };