Changeset 260

Show
Ignore:
Timestamp:
07/20/11 04:41:26 (10 months ago)
Author:
erik
Message:

Fix of getDigestPointsOnly, it did not pay attention to "endPath" and "beginPath".

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/Lib/robofab/pens/digestPen.py

    r26 r260  
    4141                return tuple(self._data) 
    4242         
    43         def getDigestPointsOnly(self): 
    44                 """Return a tuple with all coordinates of all points,  
     43        def getDigestPointsOnly(self, needSort=True): 
     44                """ Return a tuple with all coordinates of all points,  
    4545                        but without smooth info or drawing instructions. 
    4646                        For instance if you want to compare 2 glyphs in shape, 
     
    4848                        """ 
    4949                points = [] 
     50                from types import TupleType 
    5051                for item in self._data: 
    51                         points.append(item[0]) 
    52                 points.sort() 
     52                        if type(item) == TupleType: 
     53                                points.append(item[0]) 
     54                if needSort: 
     55                        points.sort() 
    5356                return tuple(points) 
    5457 
     
    6770                self._data.append(baseGlyphName) 
    6871 
     72if __name__ == "__main__": 
     73        """ 
     74         
     75        beginPath 
     76        ((112, 651), 'line', False, None) 
     77        ((112, 55), 'line', False, None) 
     78        ((218, 55), 'line', False, None) 
     79        ((218, 651), 'line', False, None) 
     80        endPath 
     81         
     82        """ 
     83        # a test 
     84         
     85        from robofab.objects.objectsRF import RGlyph 
     86         
     87        g = RGlyph() 
     88        p = g.getPen() 
     89        p.moveTo((112, 651)) 
     90        p.lineTo((112, 55)) 
     91        p.lineTo((218, 55)) 
     92        p.lineTo((218, 651)) 
     93        p.closePath() 
     94         
     95        print g, len(g) 
     96         
     97        digestPen = DigestPointPen() 
     98        g.drawPoints(digestPen) 
     99 
     100        print 
     101        print "getDigest", digestPen.getDigest() 
     102         
     103        print 
     104        print "getDigestPointsOnly", digestPen.getDigestPointsOnly() 
     105         
     106