fontello / svg2ttf

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

Provide an option to allow duplicate glyphs #85

Closed mririgoyen closed 5 years ago

mririgoyen commented 5 years ago

We're trying to use the webfont module to create an icon font. However, it uses this module to convert svg to ttf. One of the things that happens during this conversion is the deduping of identical glyphs. (See https://github.com/fontello/svg2ttf/blob/master/lib/svg.js#L36)

This is problematic; we need the ability to have duplicate glyphs in some edge cases.

Please provide a configuration option to disable this process.

puzrin commented 5 years ago

As far as i remember, that function deduplicates glyph countours table entries. I don't understand, how this can be related to your case.

Do you have more detailed description of your problem and reproducible sample?

mririgoyen commented 5 years ago

Sure, I've dumbed this down quite a bit to make a minimally reproducible example.

Here is the output SVG using webfont:

<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" >
<svg xmlns="http://www.w3.org/2000/svg">
<defs>
  <font id="my-icons" horiz-adv-x="512">
    <font-face font-family="my-icons"
      units-per-em="512" ascent="512"
      descent="0" />
    <missing-glyph horiz-adv-x="0" />
    <glyph glyph-name="alpha-o" unicode="&#x4F;" horiz-adv-x="512" d="M234.6666666666667 362.6666666666667A42.666666666666664 42.666666666666664 0 0 1 192 320V192A42.666666666666664 42.666666666666664 0 0 1 234.6666666666667 149.3333333333334H277.3333333333333A42.666666666666664 42.666666666666664 0 0 1 320 192V320A42.666666666666664 42.666666666666664 0 0 1 277.3333333333333 362.6666666666667H234.6666666666667M234.6666666666667 320H277.3333333333333V192H234.6666666666667V320z" />
    <glyph glyph-name="numeric-0" unicode="&#x30;" horiz-adv-x="512" d="M234.6666666666667 362.6666666666667A42.666666666666664 42.666666666666664 0 0 1 192 320V192A42.666666666666664 42.666666666666664 0 0 1 234.6666666666667 149.3333333333334H277.3333333333333A42.666666666666664 42.666666666666664 0 0 1 320 192V320A42.666666666666664 42.666666666666664 0 0 1 277.3333333333333 362.6666666666667H234.6666666666667M234.6666666666667 320H277.3333333333333V192H234.6666666666667V320z" />
    <glyph glyph-name="music-note" unicode="&#xF387;" horiz-adv-x="512" d="M256 448V222.9333333333333C243.4133333333334 230.1866666666667 228.9066666666667 234.6666666666667 213.3333333333333 234.6666666666667C166.1866666666667 234.6666666666667 128 196.48 128 149.3333333333334S166.1866666666667 64 213.3333333333333 64S298.6666666666667 102.1866666666667 298.6666666666667 149.3333333333334V362.6666666666667H384V448H256z" />
    <glyph glyph-name="music-note-eighth" unicode="&#xF388;" horiz-adv-x="512" d="M256 448V222.9333333333333C243.4133333333334 230.1866666666667 228.9066666666667 234.6666666666667 213.3333333333333 234.6666666666667C166.1866666666667 234.6666666666667 128 196.48 128 149.3333333333334S166.1866666666667 64 213.3333333333333 64S298.6666666666667 102.1866666666667 298.6666666666667 149.3333333333334V362.6666666666667H384V448H256z" />
  </font>
</defs>
</svg>

Run that through svg2ttf, the output TTF file will contain 3 glyphs, a blank one and 2 others.


EDIT: Perhaps that dudupe function can consider glyph-name and/or unicode as well? That seems like an even better solution and would require less changes upstream.