summaryrefslogtreecommitdiff
path: root/fontpipeline/fontpipeline_slides.py
blob: 2526c3aad2caf5c04b8188fab8b455965302eccd (plain)
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
#!/usr/bin/python
# -*- coding:utf8 -*-

# Copyright 2016 Behdad Esfahbod <behdad@google.com>

# A slides file should populate the variable slides with
# a list of tuples.  Each tuple should have:
#
#	- Slide content
#	- User data
#	- Canvas width
#	- Canvas height
#
# Slide content can be a string, a list of strings,
# a function returning one of those, or a generator
# yielding strings.  The user data should be a dictionary or
# None, and is both used to communicate options to the
# renderer and to pass extra options to the theme functions.
#
# A function-based slide content will be passed a renderer object.
# Renderer is an object similar to a cairo.Context and
# pangocairo.CairoContext but has its own methods too.
# The more useful of them here are put_text, put_image, and
# set_allocation.  See their pydocs.

title_font="Impact"
head_font="noto sans" # "Oswald Bold"
body_font="noto sans light 50" # "PT Sans"
xbody_font="noto sans thin 200" # "PT Sans"
mono_font="Consolas, monospace"

slides = []
def slide_add(f, data=None, width=1920, height=1024):
	if data is None:
		data = {}
	if "desc" not in data:
		data['desc'] = body_font
	slides.append ((f, data, width, height))
	return f

import pango, pangocairo, cairo

# And convenience functions to add a slide.  Can be
# used as a function decorator, or called directly.
def slide(f, data=None, scale=None):
	if data:
		data = dict (data)
	else:
		data = {}
	if not scale: scale = 1.
	def slider(r):
		r.move_to (50, 30)
		r.scale(scale, scale)
		r.put_text (f, valign=1, halign=1, desc=body_font)
		#r.set_allocation (x, y, width, height)
	if isinstance(f, basestring):
		return slide_add (slider, data)
	return slide_add (f, data)

def slide_big(f, data=None, scale=None):
	if data:
		data = dict (data)
	else:
		data = {}
	if not scale: scale = 1
	def slider(r):
		r.move_to (960, 512)
		r.scale(scale, scale)
		r.put_text (f, valign=0, halign=0, desc=xbody_font)
		#r.set_allocation (x, y, width, height)
	if isinstance(f, basestring):
		return slide_add (slider, data)
	return slide_add (f, data)

def slide_title (title, text, scale=None):
	ts = '' if not title else "<span font_desc='"+head_font+"'>"+title+"</span>\n\n"
	ts = ts + text.strip()
	#s.__name__ = title
	data={'desc': body_font, 'align': pango.ALIGN_LEFT}
	slide (ts, data, scale=scale)
def bullet_list_slide (title, items):
	ts = "<span font_desc='"+head_font+"'>"+title+"</span>\n\n"
	ts = ts + '\n'.join ("- " + item for item in items)
	#s.__name__ = title
	data={'desc': body_font, 'align': pango.ALIGN_LEFT}
	slide (ts, data)

def image_slide (f, width=1920, height=1024, imgwidth=0, imgheight=0, xoffset=0, yoffset=0, data=None):
	def s (r):
		r.move_to (960+xoffset, 512+yoffset)
		r.put_image (f, width=imgwidth, height=imgheight)
		x = (1920 - width) * .5
		y = (1024 - height) * .5
		r.set_allocation (x, y, width, height)
	s.__name__ = f
	slide (s, data)
	return s

#
# Slides start here
#

@slide
def title_slide (r):
	r.move_to (30, 1000)
	r.save()
	r.set_source_rgb(0xf6/255., 0x48/255., 0x48/255.)
	r.put_text ("<span font_desc='"+title_font+"' font_size='large'>The\nOpen\nSource\n"+
		    "Python\nFont\nProduction\nPipeline</span>",
		    valign=-1, halign=1, desc=title_font+" 72")

	r.restore()
	r.move_to (1890, 1000)
	r.scale(1.4, 1.4)
	r.put_text ("Marek Jeziorek\nBehdad Esfahbod\nGoogle", halign=-1, valign=-1)

slide_big("FontTools")
slide_big("UFO")
slide_big("ATypI 2014")
slide_big("FontTools")
slide_big("AFDKO")
slide_big("Noto")

bullet_list_slide("Noto pipeline", [
	"glyphs2ufo",
	"robofab vs extractor",
	])

bullet_list_slide("Noto pipeline", [
	"glyphs2ufo",
	"robofab",
	"ufo2fdk",
	])

bullet_list_slide("Noto pipeline: feaLib", [
	"glyphs2ufo",
	"robofab",
	"ufo2fdk → ufo2ft",
	"fontTools.feaLib",
	"booleanOperations",
	])

bullet_list_slide("Noto pipeline: mtiLib", [
	"glyphs2ufo",
	"robofab",
	"ufo2fdk → ufo2ft",
	"fontTools.feaLib / fontTools.mtiLib",
	"booleanOperations",
	])

bullet_list_slide("Noto pipeline: MutatorMath", [
	"glyphs2ufo",
	"robofab",
	"MutatorMath",
	"ufo2fdk → ufo2ft",
	"fontTools.feaLib",
	"booleanOperations",
	])

bullet_list_slide("Noto pipeline: cu2qu", [
	"glyphs2ufo",
	"robofab",
	"MutatorMath",
	"ufo2fdk → ufo2ft",
	"fontTools.feaLib",
	"booleanOperations",
	"cu2qu",
	])

bullet_list_slide("Noto pipeline: defcon", [
	"glyphs2ufo",
	"ufoLib",
	"<span strikethrough='true'>robofab</span> → defcon",
	"MutatorMath",
	"ufo2fdk → ufo2ft",
	"fontTools.feaLib",
	"booleanOperations",
	"cu2qu",
	])

bullet_list_slide("Noto pipeline", [
	"glyphs2ufo",
	"ufoLib",
	"defcon",
	"MutatorMath",
	"ufo2fdk → ufo2ft",
	"fontTools.feaLib",
	"booleanOperations",
	"cu2qu",
	])

bullet_list_slide("Noto pipeline: compreffor", [
	"glyphs2ufo",
	"ufoLib",
	"defcon",
	"MutatorMath",
	"ufo2fdk → ufo2ft",
	"fontTools.feaLib",
	"booleanOperations",
	"cu2qu",
	"compreffor",
	])

bullet_list_slide("Noto pipeline: ttfautohint", [
	"glyphs2ufo",
	"ufoLib",
	"defcon",
	"MutatorMath",
	"ufo2fdk → ufo2ft",
	"fontTools.feaLib",
	"booleanOperations",
	"cu2qu",
	"compreffor",
	"ttfautohint",
	])

bullet_list_slide("Noto pipeline: fontmake", [
	"glyphs2ufo",
	"ufoLib",
	"defcon",
	"MutatorMath",
	"ufo2fdk → ufo2ft",
	"fontTools.feaLib",
	"booleanOperations",
	"cu2qu",
	"compreffor",
	"ttfautohint",
	"fontmake",
	])

image_slide("pipeline.png", imgwidth=1900, imgheight=1000)
image_slide("jenga2.jpg")

bullet_list_slide("Noto pipeline: challenges", [
	"Dependency hell",
	"Stability",
	"Speed",
	"Flexibility",
])

bullet_list_slide("Noto pipeline: TODO", [
	"fontTools.varLib",
	"CFF operator specializer",
	"FDK hinter",
])

slide_title("", """
github.com/googlei18n/fontmake
github.com/googlei18n/glyphsLib
github.com/unified-font-object/ufoLib
github.com/typesupply/defcon
github.com/LettError/MutatorMath
github.com/typesupply/fontMath
github.com/googlei18n/ufo2ft
github.com/typemytype/booleanOperations
github.com/googlei18n/cu2qu
github.com/googlei18n/compreffor
github.com/behdad/fonttools
github.com/googlei18n/noto-source
www.freetype.org/ttfautohint/
""")

slide_big("Q&amp;A")

if __name__ == "__main__":
	import slippy
	import fontpipeline_theme
	slippy.main (slides, fontpipeline_theme, args=['--geometry', '1920x1024'])