chiark / gitweb /
Minimally-functional code for expanding dots.
authorBen Harris <bjh21@bjh21.me.uk>
Thu, 8 Mar 2018 22:33:36 +0000 (22:33 +0000)
committerBen Harris <bjh21@bjh21.me.uk>
Thu, 8 Mar 2018 22:33:36 +0000 (22:33 +0000)
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

index 346ed1b63ed7e75ad8285ccf4e5ca63c9a6dfcf0..aa063cc9c30d4d17065ff9660b3a206487474846 100644 (file)
@@ -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"