From fcbb3c8d90190552d025bec4557fa3bdc35d82cb Mon Sep 17 00:00:00 2001 From: Ben Harris Date: Thu, 8 Mar 2018 22:33:36 +0000 Subject: [PATCH] Minimally-functional code for expanding dots. It takes a little bit of effort to avoid segfaulting FontForge, and so currently Bedstead Plotter Thin has dots in the middle of its dots. These probably shouldn't stay. --- strokefont.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/strokefont.py b/strokefont.py index 346ed1b..aa063cc 100644 --- a/strokefont.py +++ b/strokefont.py @@ -14,8 +14,9 @@ class Stroker(object): f.strokedfont = False for g in f.glyphs(): - for c in g.layers[1]: - self.adjust_contour(c) + for i, c in enumerate(list(g.layers[1])): + newc = self.adjust_contour(c) + if newc != None: g.layers[1] += newc g.stroke(*self.nib) g.removeOverlap() g.addExtrema() @@ -37,9 +38,15 @@ class Stroker(object): return f def adjust_contour(self, c): # This function just expands dots. - if len(c) != 1: return - if self.dotwidth == 0 and self.dotheight == 0: return - # insert actual modifying code here. + if len(c) != 1: return None + if self.dotwidth == 0 and self.dotheight == 0: return None + newc = fontforge.contour() + newc.moveTo(c[0].x + self.dotwidth/2, c[0].y) + newc.lineTo(c[0].x, c[0].y + self.dotheight/2) + newc.lineTo(c[0].x - self.dotwidth/2, c[0].y) + newc.lineTo(c[0].x, c[0].y - self.dotheight/2) + newc.closed = True + return newc class Plotter(Stroker): familyname = "Bedstead Plotter" -- 2.30.2