We depend on the fontkit module for generating SVGs font fonts, and we discovered that it's possible to enter an infinite loop when trying to layout a font with multiple substitutions. Basically the GSUBProcessor's applyLookup function can add elements onto this.glyphs, which is a reference to the same array that we use to determine the termination condition of the while loop in OTProcessor's applyLookups.
So the problem is that we can add >1 glyph onto glyphs via applyLookup but we only ever increment this.glyphIterator by 1, which causes this.glyphIterator.index < glyphs.length to always return false.
I dont know very much about fonts, so I would love feedback on this fix if it's not semantically correct! I've run the test suite provided via npm run test and all tests continue to pass. Thanks for making fontkit!
We depend on the fontkit module for generating SVGs font fonts, and we discovered that it's possible to enter an infinite loop when trying to layout a font with multiple substitutions. Basically the
GSUBProcessor
'sapplyLookup
function can add elements ontothis.glyphs
, which is a reference to the same array that we use to determine the termination condition of the while loop inOTProcessor
'sapplyLookups
.So the problem is that we can add >1 glyph onto
glyphs
viaapplyLookup
but we only ever incrementthis.glyphIterator
by 1, which causesthis.glyphIterator.index < glyphs.length
to always return false.I dont know very much about fonts, so I would love feedback on this fix if it's not semantically correct! I've run the test suite provided via
npm run test
and all tests continue to pass. Thanks for making fontkit!