def _flushContour(self, segments):
        #
        # adapted from robofab.pens.adapterPens.rfUFOPointPen
        #
        assert len(segments) >= 1
        # if we only have one point and it has a name, we must have an anchor
        first = segments[0]
        segmentType, points = first
        pt, smooth, name, kwargs = points[0]
        if len(segments) == 1 and name != None:
            self.glyph.appendAnchor(name, pt)
            return
        else:
            segmentType, points = segments[-1]
            movePt, smooth, name, kwargs = points[-1]
            if smooth:
                # last point is smooth, set pen to start smooth
                self.subPen.setLastSmooth(True)
            if segmentType == 'line':
                    del segments[-1]

        self.subPen.moveTo(movePt)

        # do the rest of the segments
        for segmentType, points in segments:
            isSmooth = True in [smooth for pt, smooth, name, kwargs in points]
            pp = [pt for pt, smooth, name, kwargs in points]
            if segmentType == "line":
                    assert len(pp) == 1
                    if isSmooth:
                        self.subPen.smoothLineTo(pp[0])
                    else:
                        self.subPen.lineTo(pp[0])
            elif segmentType == "curve":
                    assert len(pp) == 3
                    if isSmooth:
                        self.subPen.smoothCurveTo(*pp)
                    else:
                        self.subPen.curveTo(*pp)
            elif segmentType == "qcurve":
                    assert 0, "qcurve not supported"
            else:
                    assert 0, "illegal segmentType: %s" % segmentType
        self.subPen.closePath()
dataset/ETHPy150Open google/roboto/scripts/lib/fontbuild/curveFitPen.py/SubsegmentsToCurvesPointPen._flushContour/original