lib/svg.js
function toSfntCoutours(svgPath) {
  var resContours = [];
  var resContour = [];

  svgPath.iterate(function (segment, index, x, y) {

    //start new contour
    if (index === 0 || segment[0] === 'M') {
      resContour = [];
      resContours.push(resContour);
    }

    var name = segment[0];

    if (name === 'Q') {
      //add control point of quad spline, it is not on curve
      resContour.push({ x: segment[1], y: segment[2], onCurve: false });
    }

    // add on-curve point
    if (name === 'H') {
      // vertical line has Y coordinate only, X remains the same
      resContour.push({ x: segment[1], y: y, onCurve: true });
    } else if (name === 'V') {
      // horizontal line has X coordinate only, Y remains the same
      resContour.push({ x: x, y: segment[1], onCurve: true });
    } else if (name !== 'Z') {
      // for all commands (except H and V) X and Y are placed in the end of the segment
      resContour.push({ x: segment[segment.length - 2], y: segment[segment.length - 1], onCurve: true });
    }

  });
  return resContours;
}
function toSfntCoutours(svgPath) {
  var resContours = [];
  var resContour = [];

  svgPath.iterate(function (segment, index, x, y) {

    //start new contour
    if (index === 0 || segment[0] === 'M') {
      resContour = [];
      resContours.push(resContour);
    }

    var name = segment[0];

    if (name === 'Q') {
      //add control point of quad spline, it is not on curve
      resContour.push({ x: segment[1], y: segment[2], onCurve: false });
    }

    // add on-curve point
    if (name === 'H') {
      // vertical line has Y coordinate only, X remains the same
      resContour.push({ x: segment[1], y: y, onCurve: true });
    } else if (name === 'V') {
      // horizontal line has X coordinate only, Y remains the same
      resContour.push({ x: x, y: segment[1], onCurve: true });
    } else if (name !== 'Z') {
      // for all commands (except H and V) X and Y are placed in the end of the segment
      resContour.push({ x: segment[segment.length - 2], y: segment[segment.length - 1], onCurve: true });
    }

  });
  return resContours;
}
function toSfntCoutours ( svgPath ) { var resContours = [ ] ; var resContour = [ ] ; svgPath . iterate ( function ( segment , index , x , y ) { //start new contour if ( index === 0 || segment [ 0 ] === 'M' ) { resContour = [ ] ; resContours . push ( resContour ) ; } var name = segment [ 0 ] ; if ( name === 'Q' ) { //add control point of quad spline, it is not on curve resContour . push ( { x : segment [ 1 ] , y : segment [ 2 ] , onCurve : false } ) ; } // add on-curve point if ( name === 'H' ) { // vertical line has Y coordinate only, X remains the same resContour . push ( { x : segment [ 1 ] , y : y , onCurve : true } ) ; } else if ( name === 'V' ) { // horizontal line has X coordinate only, Y remains the same resContour . push ( { x : x , y : segment [ 1 ] , onCurve : true } ) ; } else if ( name !== 'Z' ) { // for all commands (except H and V) X and Y are placed in the end of the segment resContour . push ( { x : segment [ segment . length - 2 ] , y : segment [ segment . length - 1 ] , onCurve : true } ) ; } } ) ; return resContours ; }
Converts svg points to contours.  All points must be converted to relative ones, smooth curves must be converted to generic ones before this conversion.
Converts svg points to contours . All points must be converted to relative ones smooth curves must be converted to generic ones before this conversion .