chiark / gitweb /
Skeleton code for adjusting dots in plotter fonts.
authorBen Harris <bjh21@bjh21.me.uk>
Sat, 3 Mar 2018 20:46:26 +0000 (20:46 +0000)
committerBen Harris <bjh21@bjh21.me.uk>
Sat, 3 Mar 2018 20:46:26 +0000 (20:46 +0000)
In light fonts, they end up almost invisible, but I have a plan.

strokefont.py

index 49494e883e0ebf7f72e279941a2a2be32c8eac11..0721f619d30531473b2ffb27f82a2378ab1a1c6b 100644 (file)
@@ -8,10 +8,14 @@ from sys import argv
 class Stroker(object):
     def __init__(self, fontname):
         self.fontname = fontname
+        self.dotwidth = max(0, 100 - self.nibwidth)
+        self.dotheight = max(0, 100 - self.nibheight)
     def modify_font(self, f):
         f.strokedfont = False
 
         for g in f.glyphs():
+            for c in g.layers[1]:
+                self.adjust_contour(c)
             g.stroke(*self.nib)
             g.removeOverlap()
             g.addExtrema()
@@ -30,7 +34,12 @@ class Stroker(object):
         f.os2_weight = self.ttfweight
         f.weight = self.weight
         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.
+        
 class Plotter(Stroker):
     familyname = "Bedstead Plotter"
     def __init__(self, penwidth, weight, ttfweight):