0

I have a source of SVG files created by program potrace, which has created a separate for each component of a multi-segment character. If I simple-mindedly create glyph definitions using these same <path>s the character will not display. If I jam all the path instructions into the "d=" attribute of the <glyph> the character displays.

The SVG spec says that <glyph> elements are containers and explicitly says they can contain <path> elements. It just doesn't work (tested in Chrome, Opera, Safari).

Here's the smallest example I could cut down to:

<html>
<head>
  <meta charset="utf-8" />
  <title>SVG font test sample04</title>
  <style type="text/css">
     @font-face {
       font-family: 'sample04';
       src: url('sample04.svg#sample04') format('svg');
     }
    .sample04 { font-family: "sample04", verdana, helvetica; }
  </style>
</head>
<body class="sample04"> xE014  | &#xE014; | &#xE015; | </body>
</html>

sample04.svg

<?xml version="1.0" encoding="UTF-8" ?>
<svg version="1.1" xmlns = 'http://www.w3.org/2000/svg'>
  <defs>
    <font id="sample04" horiz-adv-x="800">
      <font-face font-family="sample04" />
      <glyph unicode="&#xE014;" horiz-adv-x="800" 
              d="M0,0h200v200h-200z M400,0h200v200h-200z"/>
      <glyph unicode="&#xE015;" horiz-adv-x="800">
        <path d="M0,0h200v200h-200z"/>
        <path d="M400,0h200v200h-200z"/>
      </glyph>
    </font>
  </defs>
</svg>

Note that the two glyphs have the same information, the first contained entirely within the <glyph> d= attribute, the second having the information separated into two <path> elements. I have tried with just a single <path> element with no better results.

So is this just another case where specs are sparkly and browsers are not up to it?

Note: the reason I care so much is that I have nearly 5000 of these SVG files to embed into a font, and didn't really want to get so heavily into XML transformations to convert the sources...

Shenme
  • 1,182
  • 1
  • 13
  • 12
  • 2
    http://www.w3.org/TR/SVGTiny12/fonts.html is a fairly accurate description of what some browsers support (Opera, Chrome/Safari). tl/dr: browsers today only support the 'd' attribute in , not arbitrary child elements. – Erik Dahlström Feb 12 '13 at 11:21
  • Thank you. Pointing out SVG Tiny as the pessimistic guide to what browsers have implemented is the best advice possible. Certainly helps understand the various asides to "stroke doesn't work", as style= is not even mentioned in SVG Tiny. – Shenme Feb 13 '13 at 02:22

0 Answers0