SOLVED Deleting all handles unexpectedly deletes entire contour



  • When I option-select all off-curve points in a contour to delete them, it sometimes results in a complete deletion of the contour. Expected result would be a leftover curveless contour.

    See screen recording for what I'm talking about


  • admin

    create bug!!

    RF decided somehow those contours are really bad... and deleted them for you, its a FEATURE!!

    fixed in the next update!!!



  • @gferreira Thanks for the code!

    @frankrolf Yeah I think it does. Doesn't always reproduce.



  • Okay, maybe this has to do with the combination of curveTos and lineTos:
    Dec-18-2019 15-07-43.gif



  • I remember the same behavior. Although, when testing it out just now (Version 3.4b (build 1912091618)), I get this:
    Dec-18-2019 15-04-05.gif



  • probably a bug… @frederik

    here’s another way of converting all curve segments to straight lines, using a pen:

    from fontTools.pens.basePen import BasePen
    
    class LinePen(BasePen):
    
        def __init__(self, otherPen):
            BasePen.__init__(self, {})
            self.otherPen = otherPen
            self.currentPt = None
            self.firstPt = None
    
        def _moveTo(self, pt):
            self.otherPen.moveTo(pt)
            self.currentPt = pt
            self.firstPt = pt
    
        def _lineTo(self, pt):
            self.otherPen.lineTo(pt)
            self.currentPt = pt
    
        def _curveToOne(self, pt1, pt2, pt3):
            self.otherPen.lineTo(pt3)
            self.currentPt = pt3
    
        def _closePath(self):
            self.lineTo(self.firstPt)
            self.otherPen.closePath()
            self.currentPt = None
    
        def _endPath(self):
            self.otherPen.endPath()
            self.currentPt = None
    
        def addComponent(self, glyphName, transformation):
            self.otherPen.addComponent(glyphName, transformation)
    
    # get a glyph with curve segments
    source = CurrentGlyph()
    # make a new temp glyph for the result
    result = RGlyph()
    # get a pen to draw into the result glyph
    drawPen = result.getPen()
    # get a pen to convert curves to lines
    linePen = LinePen(drawPen)
    # draw the result using the line pen
    source.draw(linePen)
    # replace source contours with result
    source.clearContours()
    source.appendGlyph(result)
    

    (there are probably simpler ways to do it :)

    hope this helps!