-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathHandjet-flythrough.py
64 lines (57 loc) · 1.74 KB
/
Handjet-flythrough.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
"""
Handjet flythrough glyph set animation
"""
import csv
import unicodedata
import drawBot as db
# Global settings
w, h = 400, 400
scale = 1
TEXTCOL = (0, 0, 0)
BACKCOL = (230 / 255, 250 / 255, 40 / 255)
NODECOL = (1, 1, 1)
defaults = {"wght": 400, "ELSH": 8, "ELGR": 1.01}
handjetfont = "Handjet-Regular"
# Draw a single frame
def draw(gn="a", variations={}, caption=""):
db.newPage(w * scale, h * scale)
db.scale(scale)
db.fill(*BACKCOL)
db.rect(0, 0, w, h)
fs = db.FormattedString()
fs.font(handjetfont)
fs.fontSize(200)
fs.appendGlyph(gn)
db.fill(*TEXTCOL)
db.stroke(None)
path = db.BezierPath()
path.text(fs, (w / 2, 145), align="center")
db.drawPath(path)
fs = db.FormattedString(caption, font="AdapterMonoPE-Regular", fontSize=10, fill=TEXTCOL)
db.text(fs, (w / 2, 40), align="center")
# Animate fly-through the whole glyph set
db.newDrawing()
db.font(handjetfont)
variations = defaults.copy()
unicodes = []
with open("glyphnames-unicodes-show.csv", "r") as f:
reader = csv.reader(f, delimiter=",")
# line: glyph name, unicode, whether it should be shown
for _, u, show in reader:
if u:
unicodes.append((u, eval(show)))
else:
unicodes.append((None, eval(show)))
for (u, show), gn in list(zip(unicodes, db.listFontGlyphNames())):
# show only non-empty glyphs with a width (avoiding accents and spaces)
if show:
if u:
try:
caption = unicodedata.name(chr(int(u, 16))) + "\n" + u
except ValueError:
caption = ""
else:
caption = ""
draw(gn, variations=variations, caption=caption)
db.saveImage("../../docs/animations/Handjet-flythrough.gif")
db.endDrawing()