about
Decompose a glyph outline generated from fontpath into a discrete set of points, using shape2d.
The curve/bezier approximation and simplification algorithms are very crude, but performant and sufficient for simple output.
example
//Get the data from fontpath tool var Lato = ; var decompose = ; //decompose a glyphvar glyph = Latoglyphs"b";var shapes = ; //Returns a list of shapes, e.g. the dot and stem of 'i' for var i=0; i < shapeslength; i++ var s = shapesi; //Each shape has a list of points, as Vector2 objects for var j=0; j < spointslength; j++ var p = spointsj; //...
demo
For a complete example, see the demo. You can run it with beefy:
cd fontpath-shape2d #install the tools globally npm install beefy browserify -g #install our dependencies npm install #now run the demo beefy demo/main.js
Result: