尝试为您要使用的字体添加定义(带有 url):
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="745" height="300" xml:space="preserve" xmlns:xml="http://www.w3.org/XML/1998/namespace">
<desc>TEST</desc>
<defs>
<style type="text/css">
@font-face {
font-family: "font";
src: url('COMPLETE URL TO TTF FILE eg. http://example.com/font.ttf') format('truetype');
}
</style>
</defs>
<g transform="translate(174.5 53)">
<text font-family="font" font-size="40" font-weight="normal" style="stroke: none; stroke-width: 1; stroke-dasharray: ; stroke-linecap: butt; stroke-linejoin: miter; stroke-miterlimit: 10; fill: #333; opacity: 1;" transform="translate(-98.5 39)">
<tspan x="0" y="-26" fill="#333">TEXT THAT YOU WANT TO DISPLAY</tspan>
</text>
</g>
</svg>
我有同样的问题。我在 svg 中忘记的一件事是type="text/css"。