[symfont] Handle closePath()

Apparently some draw() implementations expect closePath() to
draw a line to the contour beginning.

In fact, looks like fontTools's TrueType draw() always does the
lineTo() before closePath(), but the CFF draw() doesn't.

As raised in
https://github.com/behdad/fonttools/pull/618#issuecomment-225314022
This commit is contained in:
Behdad Esfahbod 2016-06-10 16:04:41 -07:00
parent 7822958fa5
commit c34739760c

View File

@ -82,6 +82,7 @@ class GreenPen(BasePen):
self.value += self._funcs[len(P) - 1](P)
def _moveTo(self, p0):
self.__startPoint = p0
self._segment(p0)
def _lineTo(self, p1):
@ -96,6 +97,11 @@ class GreenPen(BasePen):
p0 = self._getCurrentPoint()
self._segment(p0,p1,p2,p3)
def _closePath(self):
p0 = self._getCurrentPoint()
if p0 != self.__startPoint:
self._segment(p0,self.__startPoint)
AreaPen = partial(GreenPen, func=1)
Moment1XPen = partial(GreenPen, func=x)
Moment1YPen = partial(GreenPen, func=y)