mirror of
https://bjh21.me.uk/bedstead/.git
synced 2026-07-10 05:53:05 -04:00
It's now an integer approximation to the original 20° 100×50 rectangle that I first used.
74 lines
2.0 KiB
Python
74 lines
2.0 KiB
Python
from __future__ import print_function
|
|
|
|
import fontforge
|
|
from math import radians
|
|
from psMat import translate
|
|
from sys import argv
|
|
|
|
class Stroker(object):
|
|
def __init__(self, fontname):
|
|
self.fontname = fontname
|
|
def modify_font(self, f):
|
|
f.strokedfont = False
|
|
|
|
for g in f.glyphs():
|
|
g.stroke(*self.nib)
|
|
g.removeOverlap()
|
|
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.uwidth = self.nibheight
|
|
f.os2_weight = self.ttfweight
|
|
f.weight = self.weight
|
|
return f
|
|
|
|
class Plotter(Stroker):
|
|
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(-56, 7)
|
|
chisel.lineTo(39, 41)
|
|
chisel.lineTo(56, -7)
|
|
chisel.lineTo(-39, -41)
|
|
chisel.closed = True
|
|
self.nib = ['polygonal', chisel]
|
|
self.nibwidth = 112
|
|
self.nibheight = 82
|
|
super(Chiseltip, self).__init__(fontname)
|
|
|
|
modes = {
|
|
'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"),
|
|
}
|
|
|
|
mode = modes[argv[1]]
|
|
|
|
f = fontforge.open(argv[2])
|
|
|
|
mode.modify_font(f)
|
|
|
|
f.save(argv[3])
|
|
|