fontello / svg2ttf

SVG -> TTF font convertor
MIT License
521 stars 79 forks source link

Add support for hkern and vkern elements. #16

Closed michaelrhodes closed 4 years ago

michaelrhodes commented 10 years ago

Obviously mostly useful for traditional typefaces, but I think even for icon fonts would benefit from this feature being supported.

Example

without-kerning-pairs Without kerning pairs

with-kerning-pairs With kerning pairs

<hkern g1="diamond" g2="diamond" k="100" />
<hkern g1="home" g2="home" k="-100" />
puzrin commented 10 years ago

I can leave this ticket open as note about SVG features. But only in hope that this can be done by volunteers. Current "official" convertor support is limited to features, required by fontello. Lack of time :(

tshinnic commented 10 years ago

I really need this. So I'm going to poke at this.

Really fun is the forms that first/second glyph specifications can take with <hkern>, e.g.

    <hkern g1="C12333,C12335,C12351"       
           u2="U+E110-E122,U+E1A5,U+E3EC-E3FA,U+E405"  k="275"   />

Unicode values specified as "U+xxxxxx". Unicode ranges are allowed as "U+xxxxx-yyyyy". Multiple values and ranges with comma delimiters. Unicode values are used with u1= and u2=.

The g1= and g2= attributes reference glyph names, so <hkern> can only be processed after all the <glyph> nodes. And then we need to search the list of all glyph-names and cross-reference to unicode values.

u1= and g1= are combined to form the list of first glyphs, and u2= and g2= combined to create list of second glyphs. And I suppose accidental duplication is possible with complicated specifications like the above, so during the sort of output value pairs one might have to drop duplicates.

I'll first target only the 'kern' table, the simplest kerning table. When I look at the specs for the 'GPOS' table my head spins.

puzrin commented 10 years ago

No problems. I'll accept pull request. The only recommendation is to continue keep internal API/structures similar to FontFrorge API, when possible. May be, one day, TTF generator will be moved to separate project. This part can be useful for another tasks, not only for extracting data from SVG.

puzrin commented 4 years ago

This stays open too long, and seems nobody plan to participate. Let's close. This can be reopened anytime if someone wish to implement.