From: Ben Harris Date: Thu, 8 Mar 2018 22:33:36 +0000 (+0000) Subject: Minimally-functional code for expanding dots. X-Git-Tag: bedstead-002.000~29 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~bjharris/git?a=commitdiff_plain;h=fcbb3c8d90190552d025bec4557fa3bdc35d82cb;p=bedstead-debian.git 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. --- 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"