Here's MIT code that does that correctly. I ran into a font that would have like 3 OFF_CURVE points in a row and it rendered completely mangled. I checked OpenType.js.org and the had a glyph checker and it had different numbers of control points and resulting points. I hunted down the code from there.
It's a little weird but it fixes all the wonky text.
So the reason the shapes are wonky is that they are either all lines or quadratic bezier curves.
https://github.com/opentypejs/opentype.js/blob/c37fcdfbd89c1bd0aac1cecb2b287dfb7d00cee0/src/tables/glyf.js#L214
Here's MIT code that does that correctly. I ran into a font that would have like 3 OFF_CURVE points in a row and it rendered completely mangled. I checked OpenType.js.org and the had a glyph checker and it had different numbers of control points and resulting points. I hunted down the code from there.
It's a little weird but it fixes all the wonky text.
Less wonky inner-p contour.