Serialized SVG image with base64 embedded font, not rendering correctly in IE Edge

六眼飞鱼酱① 提交于 2021-02-08 03:43:14

问题


Edit: Issue reported to microsoft

I have a inline svg element with a custom font that is embedded as a base64 string (.woff format).

Using javscript, I am serializing the SVG element and using it as a source for an img element. Jsbin Link

var svg = document.querySelector('svg');
var svgData = new XMLSerializer().serializeToString(svg);
var img = document.createElement("img");
img.setAttribute("src", "data:image/svg+xml;base64," + btoa(svgData));
document.body.appendChild(img);
svg { width: 400px; max-width:calc(100% - 100px); height: auto; }
img { width: 400px; max-width:calc(100% - 100px); height: auto; }
<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width">
</head>

<body>
    <svg viewBox="0 -23 90 33" width="723" height="276">
        <defs>
            <style type="text/css">
                @font-face {
                    font-family: 'Butcherman';
                    src: url(data:application/font-woff;charset=utf-8;base64,d09GRgABAAAAAAgkAA0AAAAACZgAAQABAAAAAAAAAAAAAAAAAAAAAAAAAABPUy8yAAABMAAAAGAAAABgmfTQwmNtYXAAAAGQAAAATAAAAEwBDgEKY3Z0IAAAAdwAAAAEAAAABABEBRFnYXNwAAAB4AAAAAgAAAAI//8ABGdseWYAAAHoAAAEeAAABVLlx45XaGVhZAAABmAAAAA2AAAANgnzit1oaGVhAAAGmAAAACQAAAAkFLkFTGhtdHgAAAa8AAAAFAAAABQVrQCdbG9jYQAABtAAAAAMAAAADAK3A+ttYXhwAAAG3AAAACAAAAAgAFsCdW5hbWUAAAb8AAAA/QAAAewnmkT7cG9zdAAAB/wAAAAgAAAAIP9pAGZwcmVwAAAIHAAAAAcAAAAHaAaMhQADBF8BkAAFAAAFMwTMAAAAmQUzBMwAAALMAGYC8gAAAgAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAB0eXBtAEAAACISCij6rQAACigFUyAAAIEAAAAABfEF5QAAACAAAQAAAAIAAAADAAAAFAADAAEAAAAUAAQAOAAAAAoACAACAAIASABlAGwAb///AAAASABlAGwAb////7n/nf+X/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8/rE2vs5m+aMlat+nB6oRnd1LBRoIJsbfO+ZgJuCkEZNBiYjG6BR8V/ZbHL0TqIBfiABcsJII6BzAulxljYjjxgzXcIqJ5+IrlWPn2S07h/mEIu2K9Y6rdchMZoxHI02wEoWHO2JMqXhha1qA29ap5bsrUfAPqAOOY9EgXoBSacvcojz1UB7NAxrnOFDWnqblKFzL2YqWX8kyl5jIDrpmZZmim0rBIuKSEE8aBzLnU4IflATwEV+BcJHtVhAyS9kwN4vrGk+NzN/EbL39CYNDH3nzNyeseNPTtetaphYTtchNOhDtXi0jUCYGd17rI0QchJSb6PpN4b7XKe2S612j74MV2Z2uw++prf4LZIw4UIYdRy3cvb8ljxid2jQVOSGvxZuu8YN9Mpw8r3dU+29cZbhb721nPZTAiC6E3Fvsi7+f3WGXMQsaeGLH0woSIo1vf1cobLSpPt+wFvlix/gNVPNHyAAEAAAABAQbbRWJUXw889QALCAAAAAAAyxU2hQAAAADVMQmA/z36rQtRCigAAAAIAAIAAAAAAAAAAQAACij6rQAAC7T/Pf7lC1EAAQAAAAAAAAAAAAAAAAAAAAUC7ABEBdD/+gUPABoDgwAQBF4ANQAAAAAAwwFCAfQCqQABAAAABQFdAAkBFAAJAAIAAAABAAEAAABAAAAAAgABeJyNkM1OwkAUhb8RNLjpigeYGBaaYEXCChIXkriRaEL8WRt+KklLm7ZgeAUfwifwyXwKz5TZSLowkzv3zLnn3Jm5QIslDUzzFPhU7LGhrdMeHxHw5XGDG749btLhx+NjrAk8PqFjQo8DBmbKmJSMHTkrIt4psZwz40K5T49rra7wkzSZtIlizVy7Yz/kKuWyTFlQKHK22udi7iql6/fAm3wLIcsZt2zEzuRy6kS1tdiwlnddI/GxTrle494TVnnAiGfueVX3Ua338sBdp7EHmpeqVuhXaVX9e6P91z1uhqVmNeRKq5DazTYTV6iT6x0rp2Ij1R81p8kvD0BJuQAAAAADAAAAAAAA/2YAZgAAAAAAAAAAAAAAAAAAAAAAAAAAuAH/hbAEjQA=) format('woff');
                }
            </style>
        </defs>
        <text x="0.5" y="1" font-size="30" fill="#432329" stroke="#000000" stroke-width="1.2" paint-order="stroke"
            font-weight="normal" letter-spacing="1" font-family="Butcherman">Hello</text>
    </svg>
    <br />
</body>

</html>

The custom font renders correctly in Chrome, Firefox, IE 11 but not in Edge.

Have I missed something? What should I do to make the custom font render properly in Edge?

来源:https://stackoverflow.com/questions/57122843/serialized-svg-image-with-base64-embedded-font-not-rendering-correctly-in-ie-ed

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!