Skip to content

Commit

Permalink
[ttf] implement _closePath() to draw missing lines
Browse files Browse the repository at this point in the history
  • Loading branch information
midichef authored and saulpw committed Jul 29, 2023
1 parent 92fdc33 commit 6e60ed6
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions visidata/loaders/ttf.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,18 +60,32 @@ class GlyphPen(InvertedCanvas, BasePen):
aspectRatio = 1.0
def __init__(self, name, **kwargs):
super().__init__(name, **kwargs)
self.path_firstxy = None
self.lastxy = None
self.attr = self.plotColor(('glyph',))

def _moveTo(self, xy):
self.lastxy = xy
if self.path_firstxy is None:
self.path_firstxy = xy

def _lineTo(self, xy):
x1, y1 = self.lastxy
x2, y2 = xy
self.line(x1, y1, x2, y2, self.attr)
self._moveTo(xy)

def _closePath(self):
if self.path_firstxy:
if (self.path_firstxy != self.lastxy):
self._lineTo(self.path_firstxy)
self.path_firstxy = None
self.lastxy = None

def _endPath(self):
self.path_firstxy = None
self.lastxy = None

def _curveToOne(self, xy1, xy2, xy3):
vd.error('NotImplemented')

Expand Down

0 comments on commit 6e60ed6

Please sign in to comment.