mirror of
https://bjh21.me.uk/bedstead/.git
synced 2026-07-30 15:33:25 -04:00
Beginnings of a script to stroke fonts.
The plan is that bedstead.c will produce a single-path font and then this script will stroke it in various ways, adapting the font metadata appropriately.
This commit is contained in:
parent
63b418811a
commit
2c5fc3b5bc
57
strokefont.py
Normal file
57
strokefont.py
Normal file
@ -0,0 +1,57 @@
|
||||
from __future__ import print_function
|
||||
|
||||
import fontforge
|
||||
from math import radians
|
||||
from psMat import translate
|
||||
from sys import argv
|
||||
|
||||
chisel = fontforge.contour()
|
||||
chisel.moveTo(-50, 0)
|
||||
chisel.lineTo(28, 45)
|
||||
chisel.lineTo(50, 0)
|
||||
chisel.lineTo(-28, -45)
|
||||
chisel.closed = True
|
||||
|
||||
modes = {
|
||||
'plotter-thin': {
|
||||
'nib': ['circular', 10, 'round', 'round'],
|
||||
'vshift': 5,
|
||||
'fontname': "BedsteadPlotter-Thin",
|
||||
},
|
||||
'plotter-light': {
|
||||
'nib': ['circular', 50, 'round', 'round'],
|
||||
'vshift': 25,
|
||||
'fontname': "BedsteadPlotter-Light",
|
||||
},
|
||||
'plotter-medium': {
|
||||
'nib': ['circular', 100, 'round', 'round'],
|
||||
'vshift': 50,
|
||||
'fontname': "BedsteadPlotter-Medium",
|
||||
},
|
||||
'plotter-bold': {
|
||||
'nib': ['circular', 150, 'round', 'round'],
|
||||
'vshift': 75,
|
||||
'fontname': "BedsteadPlotter-Bold",
|
||||
},
|
||||
'chiseltip': {
|
||||
'nib': ['polygonal', chisel],
|
||||
'vshift': 45,
|
||||
'fontname': "BedsteadChiseltip",
|
||||
},
|
||||
}
|
||||
|
||||
mode = modes[argv[1]]
|
||||
|
||||
f = fontforge.open(argv[2])
|
||||
|
||||
f.strokedfont = False
|
||||
|
||||
for g in f.glyphs():
|
||||
g.stroke(*mode['nib'])
|
||||
g.removeOverlap()
|
||||
g.addExtrema()
|
||||
g.transform(translate(0, mode['vshift']))
|
||||
|
||||
f.fontname = mode['fontname']
|
||||
f.save(argv[3])
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user