chiark / gitweb /
strokefont: Better font name handling
authorBen Harris <bjh21@bjh21.me.uk>
Sat, 12 Aug 2017 09:05:52 +0000 (10:05 +0100)
committerBen Harris <bjh21@bjh21.me.uk>
Sat, 12 Aug 2017 09:05:52 +0000 (10:05 +0100)
This gets the PostScript names right.  TTF names are more difficult.

strokefont.py

index d0a39d485205f579a2b7dba5f595643aef61332b..75f315a25c06b9d518a5a3c01d93a94a962ace84 100644 (file)
@@ -17,18 +17,31 @@ class Stroker(object):
             g.addExtrema()
             g.transform(translate(0, self.nibheight/2.0))
 
+        f.familyname = self.familyname
         f.fontname = self.fontname
+        f.fullname = self.fullname
         f.private['StdHW'] = self.nibheight
         f.private['StdVW'] = self.nibwidth
+        f.os2_weight = self.ttfweight
+        f.weight = self.weight
         return f
 
 class Plotter(Stroker):
-    def __init__(self, penwidth, weight):
+    familyname = "Bedstead Plotter"
+    def __init__(self, penwidth, weight, ttfweight):
         self.nib = ['circular', penwidth, 'round', 'round']
         self.nibwidth = self.nibheight = penwidth
+        self.fontname = "BedsteadPlotter-" + weight
+        self.fullname = "%s %s" % (self.familyname, weight)
+        self.ttfweight = ttfweight
+        self.weight = weight
         super(Plotter, self).__init__("BedsteadPlotter-" + weight)
 
 class Chiseltip(Stroker):
+    familyname = "Bedstead Chiseltip"
+    fullname = "Bedstead Chiseltip"
+    weight = "Medium"
+    ttfweight = 500
     def __init__(self, fontname):
         chisel = fontforge.contour()
         chisel.moveTo(-50, 0)
@@ -42,10 +55,10 @@ class Chiseltip(Stroker):
         super(Chiseltip, self).__init__(fontname)
 
 modes = {
-    'plotter-thin': Plotter(10, "Thin"),
-    'plotter-light': Plotter(50, "Light"),
-    'plotter-medium': Plotter(100, "Medium"),
-    'plotter-bold': Plotter(150, "Bold"),
+    'plotter-thin': Plotter(10, "Thin", 100),
+    'plotter-light': Plotter(50, "Light", 300),
+    'plotter-medium': Plotter(100, "Medium", 500),
+    'plotter-bold': Plotter(150, "Bold", 700),
     'chiseltip': Chiseltip("BedsteadChiseltip"),
 }