Skip to content

Commit f2ea855

Browse files
committed
adding visual tests
drawbot scripts
1 parent bd21f8f commit f2ea855

2 files changed

Lines changed: 71 additions & 0 deletions

File tree

tests/testData/visualTest.pdf

138 KB
Binary file not shown.

tests/testData/visualTest.py

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# run in DrawBot RoboFont extension
2+
border = 20
3+
dotSize = 10
4+
offDotSize = dotSize * .5
5+
6+
7+
f = CurrentFont()
8+
9+
10+
def drawOffCurve(anchor, off):
11+
x, y = anchor
12+
offx, offy = off
13+
if offx or offy:
14+
offx += x
15+
offy += y
16+
with savedState():
17+
stroke(1, 0, 0)
18+
fill(1, 0, 0)
19+
line((x, y), (offx, offy))
20+
oval(offx - offDotSize, offy - offDotSize, offDotSize * 2, offDotSize * 2)
21+
22+
23+
def drawGlyphWithPoints(glyph):
24+
fill(0, .1)
25+
stroke(0)
26+
drawGlyph(glyph)
27+
stroke(None)
28+
29+
for contour in glyph:
30+
fill(0, 1, 0)
31+
for point in contour.bPoints:
32+
x, y = point.anchor
33+
drawOffCurve((x, y), point.bcpIn)
34+
drawOffCurve((x, y), point.bcpOut)
35+
oval(x - dotSize, y - dotSize, dotSize * 2, dotSize * 2)
36+
fill(1, 0, 0)
37+
38+
39+
for glyphName in f.glyphOrder:
40+
if glyphName not in f:
41+
continue
42+
g = f[glyphName]
43+
bounds = g.bounds
44+
if not bounds:
45+
continue
46+
minx, miny, maxx, maxy = bounds
47+
w = maxx - minx
48+
h = maxy - miny
49+
layerCount = len(f.layers)
50+
newPage((w + border) * layerCount + border, h + border * 2 + 100)
51+
translate(border, border + 100)
52+
translate(-minx, -miny)
53+
fontSize(20)
54+
stroke()
55+
text("%s" % g.name, (w * .5, -100 + miny), align="center")
56+
drawGlyphWithPoints(g)
57+
translate(w + border, 0)
58+
for layer in f.layers:
59+
if layer.name == "foreground":
60+
continue
61+
fill(0)
62+
text(layer.name, (w * .5, -100 + miny), align="center")
63+
if g.name not in layer:
64+
translate(w + border)
65+
continue
66+
lg = layer[g.name]
67+
drawGlyphWithPoints(lg)
68+
translate(w + border)
69+
70+
71+
saveImage("visualTest.pdf")

0 commit comments

Comments
 (0)