See https://bugzilla.mozilla.org/show_bug.cgi?id=1735738 for reference.
const svg_xml = unescape(
    encodeURIComponent(new XMLSerializer().serializeToString(svgElement))
  );
  const img = new Image();
  img.src = "data:image/svg+xml;base64," + btoa(svg_xml);
  img.onload = function () {
    ctx.drawImage(img, 0, 0);
    resolve();
  };
  img.onerror = function (e) {
    reject(new Error("Error rasterizing text layer " + e));
  };
}
function inlineImages(images) {