function calculateTextWidth(text) {
    const svg = document.createElement("svg");
    const svgText = document.createElement("text");

    svgText.style = "font-size: 9.5px; font-weight: bold; color: red; fill: red; font-family: var(--font-mono);";
    svgText.innerHTML = text;

    svg.appendChild(svgText);
    document.body.appendChild(svg);

    const textLen = svgText.getBoundingClientRect().width;

    svg.remove();

    return textLen;
  }
Given a label and optional score, return an SVG data URL to use it in regions.
Has internal caching to avoid recalculating the same SVGs.
@param {string} label Label text
@param {number} [score] Score in [0, 1] range
@returns {string} Data URL containing inline SVG already enclosed in quotes