SVG Font glyphs containing arbitrary SVG content

Robert O'Callahan <[email protected]> Thu, 10 Sep 2009 10:48:29 +1200
Newsgroups gmane.comp.mozilla.devel.svg
Organization Mozilla Corporation
Message-ID <[email protected]>
On 10/09/09 9:35 AM, Rick wrote:
> There isn't anything a TTF font can do that SVG Fonts can't do

There certainly is: for example hinting and advanced shaping. But that's 
not really relevant to this discussion, so never mind.

> the only thing SVG fonts can do that TTF fonts can't do is merge SVG rendering with
> text semantics.
>
> But that one thing is very powerful.

Potentially yes; the question is how useful it is.

> And if you have text metrics/semantics and SVG rendering, the job is almost
> done for you already.

Not really. Implementing the rendering for <glyph d="..."/> looks pretty 
easy. But the glyph elements can contain arbitrary SVG --- and via 
foreignObject, non-SVG --- content and the spec requires that content to 
be treated as a per-glyph <use> element with CSS cascading into the 
cloned anonymous content in a complicated way. For example, consider a 
font whose "G" glyph is an HTML <iframe> containing www.google.com, we'd 
have to create a bunch of anonymous iframes somehow associated with each 
text node, figure out what happens to the state of those iframes as the 
node is edited, etc.

However, I just tried to see how Webkit and Opera handle arbitrary SVG 
content in glyphs, using this simple example:

<svg xmlns="http://www.w3.org/2000/svg" >
   <font id="Font">
     <font-face font-family="Test" units-per-em="2048"/>
	<glyph unicode="@" horiz-adv-x="1000" d="M128 0V1638H896V0H128zM256 
128H768V1510H256V128z">
	  <rect x="0" y="0" width="1000" height="1000" fill="cyan"/>
	</glyph>
   </font>
   <text x="0" y="100" style="font-family:Test; font-size:80px;">@@@</text>
</svg>

... and they don't seem to be rendering the <rect>. Is something wrong 
with my example?

I also notice that the SVG 1.1 test suite doesn't test anything but 
<glyph d="..."/>.

Rob