summaryrefslogtreecommitdiff
path: root/fonttools2016/fonttools2016_slides.py
blob: 4f945ca7091c3c024d64184427908c1580dfdf69 (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
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
#!/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"
subtitle_font="Oswald Bold"
head_font="sans Bold" # "Oswald Bold"
body_font="sans" # "PT Sans"
mono_font="Consolas, monospace"

slides = []
def slide_add(f, data=None, width=1920, height=1200):
	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, os, signal
from pangopygments import highlight

# We use slide data to tell the theme who's speaking.
# That is, which side the bubble should point to.
behdad = -1
whois = 0
def who(name):
	global whois
	whois = name

# And convenience functions to add a slide.  Can be
# used as a function decorator, or called directly.
def slide_who(f, who, data=None, scale=None):
	if data:
		data = dict (data)
	else:
		data = {}
	data['who'] = who
	if not scale: scale = 1.4
	def slider(r):
		r.move_to (100, 80)
		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(f, data=None, scale=None):
	return slide_who (f, whois, data=data, scale=scale)

def slide_heading(f, data=None):
	if data is None:
		data = {}
	if 'desc' not in data:
		data['desc'] = head_font
	if data and 'who' in data:
		return slide_who (f, data['who'], data=data)
	else:
		return slide_who (f, 0, data=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=1200, imgwidth=0, imgheight=0, xoffset=0, yoffset=0, data=None):
	def s (r):
		r.move_to (960+xoffset, 600+yoffset)
		r.put_image (f, width=imgwidth, height=imgheight)
		x = (1920 - width) * .5
		y = (1200 - height) * .5
		r.set_allocation (x, y, width, height)
	s.__name__ = f
	slide (s, data)
	return s

def draw_image (r, f, width=600, height=600, imgwidth=0, imgheight=0, xoffset=0, yoffset=0, data=None):
	r.move_to (400+xoffset, 300+yoffset)
	r.put_image (f, width=imgwidth, height=imgheight)
	x = (800 - width) * .5
	y = (600 - height) * .5
	r.set_allocation (x, y, width, height)

def source_slide(s, lang):
	s = highlight(s, lang)
	s = "<span font_desc='"+mono_font+"'>" + s + "</span>"
	slide_heading (s, data={'align': pango.ALIGN_LEFT})

def python_slide(s):
	source_slide(s, lang="py")

def xml_slide(s):
	source_slide(s, lang="xml")

def patch_slide(s):
	lines = s.split ("\n")
	new_lines = []
	for s in lines:
		s = s.replace("&", "&amp;").replace("<", "&lt;")
		if not s: s = ' '
		if s[0] == '-':
			s = "<span fgcolor='#d00'>%s</span>" % s
		elif s[0] == '+':
			s = "<span fgcolor='#0a0'>%s</span>" % s
		elif s[0] != ' ':
			s = "<b>%s</b>" % s

		new_lines.append (s)

	s = '\n'.join (new_lines)
	s = "<span font_desc='"+mono_font+"'>" + s + "</span>"
	slide_heading (s, data={'align': pango.ALIGN_LEFT})

def commit_slide(s, who=None):
	lines = s.split ("\n")
	new_lines = []
	for s in lines:
		s = s.replace("&", "&amp;").replace("<", "&lt;")
		if not s: s = ' '
		if s[0] != ' ':
			s = "<b>%s</b>" % s

		new_lines.append (s)

	s = '\n'.join (new_lines)
	s = "<span font_desc='"+mono_font+"'>" + s + "</span>"
	if who:
		slide_heading (s, data={'align': pango.ALIGN_LEFT, 'who': who})
	else:
		slide_heading (s, data={'align': pango.ALIGN_LEFT})


#
# Slides start here
#

who (behdad)

@slide
def title_slide (r):
	r.move_to (50, 100)
	r.put_text ("<span font_desc='"+title_font+"' font_size='large'>FontTools/TTX\n"+
		    "The Power of Open Source for OpenType</span>",
		    valign=1, halign=1, desc=title_font+" 72")

	r.move_to (300, 600)
	r.scale(1.4, 1.4)
	r.put_text ("Part 1: Just van Rossum\nPart 2: Behdad Esfahbod\nPart 3: Q&amp;A\n\n<span font_desc='"+mono_font+"'>github.com/behdad/fonttools</span>", halign=1, valign=+1)

def agenda(i=None):
	items = [
	]
	if i is not None:
		i = items.index(i)
		items[i] = "<span foreground='#0f007e'>%s</span>" % items[i]
	bullet_list_slide("Agenda", items)


bullet_list_slide("Background: 2003", [
	"FarsiWeb days",
	])
bullet_list_slide("Background: 2013", [
	"July: Subsetter is born",
	])
bullet_list_slide("Background: 2013", [
	"July: 'COLR'/'CPAL' table",
	"August: Google color fonts",
	"August: 'SVG ' table from Read Roberts",
	"August: Cosimo shows up",
	"August: Remove numpy dependency",
	"September: 'sbix' table form Jens Kutilek",
	"October: ATypI 2013 Amsterdam",
	"November: Port to Python 2/3",
	"...",
	])

bullet_list_slide("2014", [
	"Optimized the subsetter",
	"Implemented merger",
	"Hooked up the test suite",
	"Released 2.5",
	"ATypI 2014 Barcelona",
	])

bullet_list_slide("2015", [
	"Sascha joiners",
	"gvar/fvar/avar",
	"Noto pipeline starts",
	"Released 3.0",
	"ATypI 2015 Saõ Paulo",
	"Coninuous integration",
	])

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

slide_title("2015-01", """
https://github.com/robofab-developers/robofab/pull/29

@letterror:
Does this pull make robofab dependent on a
specific fork of FontTools?
""")

slide_title("2015-04", """
https://github.com/typesupply/compositor/issues/7

Subject: test Coverage object if it has a Format attr

@typemytype:
a small patch to make compositor work with the github
fontTools version

@typesupply:
Is there a change list somewhere of all the things that
you've done since forking from the original FontTools?
We're running into lots of things so it would be good to
have something to review.
""", scale=1.3)

image_slide("lucky-cat.jpg")

slide_title("\n\n", """
"These Dutch people..."

"Google forked us..."
""")

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("OpenType 2.0 / GX / Saõ Paulo", '')

slide_title("2015-11-26","""
From: Behdad Esfahbod
To: Erik van Blokland

Hi Erik,

I'm planning to visit The Hague in January, mostly to
meet Bahman, and hopefully to work with you.  We
can discuss / hack on interpolation, OpenType GX,
or really anything fonts &amp; Python.  Would you be
interested in that?  I'm thinking some time the week
of January 18th.
""")
slide_title("2015-11-27","""
From: Erik van Blokland
To: Behdad Esfahbod

Hi Behdad,

That's unexpected :) I have time that week and we
can meet earlier in the week.  I do have some
academic obligations on Thursday and Friday and
the Type and Media open day that Saturday.

Would that work for you?
""")

slide_title("2016-01-16","""
From: Erik van Blokland
To: Behdad Esfahbod

Hi Behdad,

I hope to see you next week! It’s above freezing
but a lot of rain.

Just is at the academy on Wednesday and would like
to meet you.  Frederik Berlaen lives in Gent, Belgium
and can come up on Friday or Thursday.
""")

slide_title("2016-01-20","""
Tabs or spaces?
""", scale=2)

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: fontmake", [
	"glyphs2ufo",
	"ufoLib",
	"defcon",
	"MutatorMath",
	"ufo2fdk → ufo2ft",
	"fontTools.feaLib",
	"booleanOperations",
	"cu2qu",
	"compreffor",
	"fontmake",
	])

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

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

image_slide("jenga1.jpg")
image_slide("jenga2.jpg")

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

slide_title("Eng time!", "")
slide_title("Snippets/symfont.py roboto.ttf", """
glyph: slash
Area: 0.0631374
Correlation: 0.964027
Covariance: 0.0190825
MeanX: 0.196996
MeanY: 0.324567
Moment1X: 0.0124378
Moment1Y: 0.0204923
Moment2XX: 0.00294835
Moment2XY: 0.00524173
Moment2YY: 0.00978664
Perimeter: 1.81758
Slant: 0.38425
StdDevX: 0.0888251
StdDevY: 0.222849
VarianceX: 0.0078899
VarianceY: 0.0496617
""", scale=1.0)
slide_title("compreffor", "")
slide_title("cu2qu", "")

slide_title("Links", """
github.com/googlei18n/noto-source
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
""")

slide_title("Q&amp;A", '')

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