lib/ttf/utils.js
function interpolate(contours, accuracy) {
  return _.map(contours, function (contour) {
    var resContour = [];

    _.forEach(contour, function (point, idx) {
      // Never skip first and last points
      if (idx === 0 || idx === (contour.length - 1)) {
        resContour.push(point);
        return;
      }

      var prev = contour[idx - 1];
      var next = contour[idx + 1];

      var p, pPrev, pNext;

      // skip interpolateable oncurve points (if exactly between previous and next offcurves)
      if (!prev.onCurve && point.onCurve && !next.onCurve) {
        p = new math.Point(point.x, point.y);
        pPrev = new math.Point(prev.x, prev.y);
        pNext = new math.Point(next.x, next.y);
        if (pPrev.add(pNext).div(2).sub(p).dist() < accuracy) {
          return;
        }
      }
      // keep the rest
      resContour.push(point);
    });
    return resContour;
  });
}
function interpolate(contours, accuracy) {
  return _.map(contours, function (contour) {
    var resContour = [];

    _.forEach(contour, function (point, idx) {
      // Never skip first and last points
      if (idx === 0 || idx === (contour.length - 1)) {
        resContour.push(point);
        return;
      }

      var prev = contour[idx - 1];
      var next = contour[idx + 1];

      var p, pPrev, pNext;

      // skip interpolateable oncurve points (if exactly between previous and next offcurves)
      if (!prev.onCurve && point.onCurve && !next.onCurve) {
        p = new math.Point(point.x, point.y);
        pPrev = new math.Point(prev.x, prev.y);
        pNext = new math.Point(next.x, next.y);
        if (pPrev.add(pNext).div(2).sub(p).dist() < accuracy) {
          return;
        }
      }
      // keep the rest
      resContour.push(point);
    });
    return resContour;
  });
}
function interpolate ( contours , accuracy ) { return _ . map ( contours , function ( contour ) { var resContour = [ ] ; _ . forEach ( contour , function ( point , idx ) { // Never skip first and last points if ( idx === 0 || idx === ( contour . length - 1 ) ) { resContour . push ( point ) ; return ; } var prev = contour [ idx - 1 ] ; var next = contour [ idx + 1 ] ; var p , pPrev , pNext ; // skip interpolateable oncurve points (if exactly between previous and next offcurves) if ( ! prev . onCurve && point . onCurve && ! next . onCurve ) { p = new math . Point ( point . x , point . y ) ; pPrev = new math . Point ( prev . x , prev . y ) ; pNext = new math . Point ( next . x , next . y ) ; if ( pPrev . add ( pNext ) . div ( 2 ) . sub ( p ) . dist ( ) < accuracy ) { return ; } } // keep the rest resContour . push ( point ) ; } ) ; return resContour ; } ) ; }
Remove interpolateable oncurve points Those should be in the middle of nebor offcurve points
Remove interpolateable oncurve points Those should be in the middle of nebor offcurve points