Typophile

Failing to create an SVG-in-OT font using ttx/fonttools

Roel N0 votes

I'm trying to create an SVG-in-OpenType font by adding an 'SVG '-table to an existing font, but the SVG glyph will not render in the final font.

This is my process:

1. I take an existing font and decompile it with ttx (Behdad's version)

2. I add an SVG table with a single svgDoc entry holding an SVG image.

3. I recompile the ttx (without errors) and test the font in Firefox (which supports SVG-in-OpenType).

Although ttx doesn't throw any errors, the SVG glyph doesn't show up — the original glyph is being shown.

My addition to the font looks like this:

<svg>
<svgDoc endGlyphID="4" startGlyphID="4">
<![CDATA[
<!-- svg data -->
]]>
</svgDoc>
<colorPalettes>
</svg>

I've tried the following:

* Using different TTF fonts to transplant my SVGs into
* Using all kinds of different SVGs, including one I took from an existing ttx'ed SVG-in-OpenType font
* Matching other tables to those of existing SVG-in-OpenType (e.g. adding a cmap_format_6 table)
* Decompiling the generated font to see if nothing was being dropped by ttx

I don't know why this doesn't work. It looks so simple, and according to various sources* adding the SVG table should be all there's to it. Inspecting proper SVG-in-OpenType fonts seems to confirm this.

Anybody have an idea what I'm doing wrong?

* https://hacks.mozilla.org/2014/10/svg-colors-in-opentype-fonts/ and http://www.microsoft.com/typography/otspec/svg.htm

Ugh. In case someone else ever runs into this: the SVG image can't be copied verbatim; something needs to be added to it. The glyph ID, as used in the GlyphOrder table ttx generates, needs to be added to the SVG. For example

<GlyphID id="4" name="exclam"/>

would need

<svg id="glyph4" ... >

And I didn't notice the IDs didn't match. Duh.

Captured from web.archive.org on 1 Jul 2017. view this capture