MCPcopy Create free account
hub / github.com/coldtype/coldtype / writeGlyph

Method writeGlyph

scripts/robofont_coldtype.py:34–63  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

32 self.writeGlyph()
33
34 def writeGlyph(self):
35 glyph = CurrentGlyph()
36 image = glyph.image
37
38 print(">>>> writeGlyph", glyph, image)
39
40 data_out = {
41 "font": CurrentFont().path,
42 "name": glyph.name,
43 "image": dict(offset=image.offset, scale=image.scale, fileName=image.__dict__["_wrapped"]["fileName"]),
44 "layers": {}
45 }
46
47 for g in glyph.layers:
48 rp = RecordingPen()
49 g.draw(rp)
50
51 contours = []
52 for c in glyph.contours:
53 contour = []
54 for pt in c.points:
55 contour.append(dict(type=pt.type, x=pt.x, y=pt.y, smooth=pt.smooth, name=pt.name))
56 contours.append(contour)
57
58 data_out["layers"][g.layer.name] = dict(
59 value=rp.value,
60 width=g.width,
61 contours=contours)
62
63 self.path.write_text(json.dumps(data_out))
64
65 def shouldDraw(self, notification):
66 if not self.w.globalToggle.get():

Callers 3

__init__Method · 0.95
windowCloseCallbackMethod · 0.95
shouldDrawMethod · 0.95

Calls 2

drawMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected