,我与使用自定义字体,以便使用该图案作为背景图像在HTML页面中的SVG图形工作作为背景图像SVG图形不显示。自定义字体在
一切都呈现精致的Chrome和Safari浏览器,但它开始在Firefox中获得搞笑:
- 火狐呈现SVG与自定义字体的文字就好了一起,当我打开SVG文件本身(到目前为止好!);
- 不过,Firefox没有不呈现自定义字体了,当同一SVG文件作为背景,以一个HTML元素(!)
我花了几个小时试图找出问题和新鲜的一双眼睛会受到欢迎。
点击此处,查看minimal demo of the issue。
这是我在很短得:
CSS:
@import url(http://fonts.googleapis.com/css?family=Indie+Flower);
body {
background: url(pattern-google.svg);
}
SVG文件:
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" xmlns:xlink="http://www.w3.org/1999/xlink" height="200" width="200">
<style type="text/css">@import url(http://fonts.googleapis.com/css?family=Indie+Flower);</style>
<defs>
<!-- Geometry -->
<g>
<rect id="square" x="0" y="0" width="200" height="200" />
</g>
<!-- Patterns with Text -->
<pattern id="pattern" x="0" y="0" width="40" height="40" patternUnits="userSpaceOnUse" text-anchor="middle" font-size="20" font-family="Indie Flower, sans-serif" style="font-family: Indie Flower, sans-serif;">
<rect x="00" y="00" width="40" height="40" fill="transparent" />
<text x="00" y="00" fill="#777">S</text>
<text x="40" y="00" fill="#777">S</text>
<text x="20" y="20" fill="#777">S</text>
<text x="00" y="40" fill="#777">S</text>
<text x="40" y="40" fill="#777">S</text>
</pattern>
</defs>
<!-- Graphics -->
<use xlink:href="#square" transform="translate(0, 0)" fill="url(#pattern)"/>
</svg>
的HTML本身其实并不重要,但我已经将它链接到下面。 我最终没有生成jsfiddle,因为我无法在那里托管SVG文件。 (在演示之外,这里的真实世界的应用是我想使用自定义字体来显示注音符号(作为背景图片,以帮助人们学习它们)。在SVG中这样做可以省去我的麻烦随时在设计中进行更改以导出到位图。)
感谢您的帮助。
从Firefox 46.0.1(或者更早的版本)开始,问题就没有了。 –