,我與使用自定義字體,以便使用該圖案作爲背景圖像在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(或者更早的版本)開始,問題就沒有了。 –