fontello/svg2ttf

fail with ligatures

Closed this issue · 13 comments

tgfjt commented

Hi!

I got Error: TypeError: Cannot read property 'length' of undefined

building a minimal sample here! (includes sample.svg)
https://github.com/tgfjt-boxbox/sample-svg2ttf/

I don't understand well but some glyph.d are undefined.
e.g. { contours: [], id: 0, height: 0, name: '', width: 0 }
https://github.com/fontello/svg2ttf/blob/master/index.js#L131

I've tried to edit svg2ttf/index.js for detecting glyph.d == undefined, and works fine.
https://github.com/tgfjt-boxbox/sample-svg2ttf#edit-svg2ttfindexjs

@sabberworm
Something wrong svg I made??
I also tried gulp-iconfont but got same error.

ref: #32

Your d attr should start with M, not with space.

Is your sample file hand-made or generated by some editor?

tgfjt commented

@puzrin
generated by svgicons2svgfont.
https://github.com/nfroidure/svgicons2svgfont/blob/master/src/index.js#L429

I just removed space and tried again but I got same Error.

Here My glyphs is:

[ { contours: [], id: 0, height: 0, name: '', width: 0 },
  { contours: [],
    id: 1,
    height: 512,
    name: 'view',
    width: 512,
    d: 'M9.468765368 264.691291L9.468765368 246.315487C123.302832 62.395646 388.931551 62.395646 502.765617 246.315487L502.765617 264.691291C388.931551 448.6111329000001 123.302832 448.6111329000001 9.468765368 264.691291zM256.117191 145.121436C193.191322 145.121436 142.283125 194.585865 142.283125 255.514946C142.283125 316.4671422 193.191322 365.8391142 256.117191 365.8391142C318.947683 365.8391142 369.951258 316.4671422 369.951258 255.514946C369.951258 194.585865 318.947683 145.121436 256.117191 145.121436z M313.034225 255.514946C313.034225 225.004177 287.544359 200.318191 256.117191 200.318191C224.690023 200.318191 199.176313 225.004177 199.176313 255.514946C199.176313 286.04883 224.690023 310.642359 256.117191 310.642359C287.544359 310.642359 313.034225 286.04883 313.034225 255.514946' },
  { contours: [], id: 2, height: 0, name: 'v', width: 0 },
  { contours: [], id: 3, height: 0, name: 'i', width: 0 },
  { contours: [], id: 4, height: 0, name: 'e', width: 0 },
  { contours: [], id: 5, height: 0, name: 'w', width: 0 } ]

No d property in { contours: [], id: 0, height: 0, name: '', width: 0 }.

tgfjt commented

FYI, before this ligatures code,
https://github.com/fontello/svg2ttf/blob/master/index.js#L97

My glyphs is just one.

[ { contours: [],
    id: '',
    height: 512,
    name: 'view',
    width: 512,
    d: 'M9.468765368 264.691291L9.468765368 246.315487C123.302832 62.395646 388.931551 62.395646 502.765617 246.315487L502.765617 264.691291C388.931551 448.6111329000001 123.302832 448.6111329000001 9.468765368 264.691291zM256.117191 145.121436C193.191322 145.121436 142.283125 194.585865 142.283125 255.514946C142.283125 316.4671422 193.191322 365.8391142 256.117191 365.8391142C318.947683 365.8391142 369.951258 316.4671422 369.951258 255.514946C369.951258 194.585865 318.947683 145.121436 256.117191 145.121436z M313.034225 255.514946C313.034225 225.004177 287.544359 200.318191 256.117191 200.318191C224.690023 200.318191 199.176313 225.004177 199.176313 255.514946C199.176313 286.04883 224.690023 310.642359 256.117191 310.642359C287.544359 310.642359 313.034225 286.04883 313.034225 255.514946' } ]

Sorry, can't promiss to dig it in nearest future. Busy with another projects.

I will have a look next week

tgfjt commented

Thank you all:smile:

It seems like SvgPath needs empty paths to be "", not undefined.

Not sure that empty paths are valid. IMHO it's better to check input and output result. Could you point to code that is affected by undefined?

Empty paths are already used for the “missingGlyph” glyph (if not found in the SVG). Now we’re also using them for synthesized glyphs for characters missing in ligatures. This is valid but we need the empty string as a default value.

Ah, i thought you talked about svgpath library.

tgfjt commented

@sabberworm
@puzrin
Thank you!!

published 2.0.2

tgfjt commented

🎉