summaryrefslogtreecommitdiff
path: root/doc/context/presentations/bachotex/2017/bachotex-2017-variablefonts.tex
blob: 08050a57d0d4f0fd7be557e712826f090141e211 (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
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
% language=uk

\setuppapersize
  [S6]

\setupbackgrounds
  [page]
  [background=color,
   backgroundcolor=darkblue]

\setuplayout
  [backspace=24pt,
   topspace=20pt,
   bottomspace=8pt,
   width=middle,
   height=middle,
   footerdistance=8pt,
   footer=8pt,
   header=0pt]

\setupcolors
  [textcolor=white]

\setupbodyfont
  [dejavu,14.4pt]

\definecolor[trace:o] [s=1]
\definecolor[trace:r] [s=1]
\definecolor[trace:do][s=1]
\definecolor[trace:dr][s=1]

\usemodule[abr-03]

\definefontfeature[noligatures][liga=no]

\setuphead
  [section]
  [page=yes,
   style=\bfb,
   after={\blank[3*medium]}]

\setuphead
  [subsection]
  [page=no,
   style=\bf\addfeature{noligatures},
   before={\blank[3*medium]},
   after={\blank}]

\setupfooter
  [strut=no,
   style=\bf]

\startuseMPgraphic{pagenumber}
    if LastPageNumber > 0 :
        draw outlinetext.f
            (decimal RealPageNumber)
            (withcolor "darkgray")
            xysized ((RealPageNumber/LastPageNumber) * TextWidth/2,FooterHeight) ;
    fi ;
\stopuseMPgraphic

\setupfootertexts
  [\useMPgraphic{pagenumber}]

\startdocument
  [title={Variable Fonts},
   subtitle={we're ready for them},
   author={Hans Hagen},
   occasion={BachoTUG 2017}]

\startstandardmakeup
    \vskip32pt
    \bfd \setupinterlinespace
    \documentvariable{title}
    \crlf
    \bfb \setupinterlinespace
    \vskip12pt
    \documentvariable{subtitle}
    \vfill
    \bfb \setupinterlinespace
    \documentvariable{author}
    \crlf
    \documentvariable{occasion}
\stopstandardmakeup

\startsubject[title=A Summary]

\startitemize
\startitem
    {\bf the macro package's view:} just a font but with many possible variations
    in shapes (width, weight, slope, etc) and therefore a bit more complex user
    interface
\stopitem
\startitem
    {\bf the engine's view:} an abstraction not different from other fonts but
    that needs a special treatment in the backend
\stopitem
\startitem
    {\bf the viewer's view:} a font to be displayed like any other with outlines
    in cff of ttf format
\stopitem
\startitem
    {\bf the user's view:} an opentype font with possibly surprising shapes of
    which you need to know a bit more than usual if you want to profit from it
\stopitem
\stopitemize

So, in practice, for most \TEX\ users it's just a font that has to be supported by
\TEX\ and friends.

\stopsubject

\startsubject[title=Starting point]

\startitemize
\startitem
    The OpenType 1.8 specification at the MicroSoft website defined the extra
    tables and explains bits and pieces.
\stopitem
\startitem
    There a few fonts that have relevant tables (not all) and implement variants
    as well as features.
\stopitem
\startitem
    There are some posts on the internet that show a bit about axis and other things
    that go on in these fonts.
\stopitem
\startitem
    Luckily we have ways (in \CONTEXT) to explore what goes on in these fonts and
    how they could look.
\stopitem
\startitem
    Condition: no tricks, no fuzzy heuristics, just the specification should be
    enough.
\stopitem
\stopitemize

\stopsubject

\startsubject[title=Implementation steps]

\startitemize
\startitem
    First try to render variants in order to see what we're dealing with. This was not too
    hard (starting with cff) because we have already virtual font support.
\stopitem
\startitem
    Next try to load the relevant tables and figure out what these deltas and such really
    mean and how axis and regions and \unknown\ have to be applied.
\stopitem
\startitem
    Try to make it all work on a real piece of text, so not only shapes but also features
    and dimensions.
\stopitem
\startitem
    Finally make sure that the font can get embedded as a normal font and not as inline
    (tagged) graphic.
\stopitem
\startitem
    Also, try to generalize the helpers and methods in such ways that we can experiment
    with additional tricks (after all, \TEX\ is about control).
\stopitem
\startitem
    Todo: once there are more fonts (with the right data tables), check the code with the
    specification.
\stopitem
\stopitemize

\stopsubject

\setupTABLE[c][1][style=tttf,align={flushleft,lohi}]

\startsubject[title=Adobe Variable Font Prototype (cff)]

\unexpanded\def\SampleFont#1#2% weight / contrast
  {\definedfont[name:adobevariablefontprototype#1*default at 32pt]It looks like this!}

\bTABLE[distance=2em,frame=off]
\bTR \bTD extralight               0/0   \eTD \bTD \SampleFont {extralight}          \eTD \eTR
\bTR \bTD light                  150/0   \eTD \bTD \SampleFont {light}               \eTD \eTR
\bTR \bTD regular                394/0   \eTD \bTD \SampleFont {regular}             \eTD \eTR
\bTR \bTD semibold               600/0   \eTD \bTD \SampleFont {semibold}            \eTD \eTR
\bTR \bTD bold                   824/0   \eTD \bTD \SampleFont {bold}                \eTD \eTR
\bTR \bTD black high contrast   1000/100 \eTD \bTD \SampleFont {blackhighcontrast}   \eTD \eTR
\bTR \bTD black medium contrast 1000/50  \eTD \bTD \SampleFont {blackmediumcontrast} \eTD \eTR
\bTR \bTD black                 1000/0   \eTD \bTD \SampleFont {black}               \eTD \eTR
\eTABLE

\stopsubject

% \starttyping
% \definefont
%   [MyLightFont]
%   [name:adobevariablefontprototypelight*default]
% \stoptyping

\unexpanded\def\SampleFont#1#2% weight / width
  {\definedfont[name:avenirnextvariable#1*default at 32pt]It looks like this!}

\startsubject[title=Avenir Next Variable (ttf)]

\bTABLE[distance=2em,frame=off]
\bTR \bTD regular           400/100 \eTD \bTD \SampleFont {regular}         \eTD \eTR
\bTR \bTD medium            500/100 \eTD \bTD \SampleFont {medium}          \eTD \eTR
\bTR \bTD bold              700/100 \eTD \bTD \SampleFont {bold}            \eTD \eTR
\bTR \bTD heavy             900/100 \eTD \bTD \SampleFont {heavy}           \eTD \eTR
\bTR \bTD condensed         400/75  \eTD \bTD \SampleFont {condensed}       \eTD \eTR
\bTR \bTD medium condensed  500/75  \eTD \bTD \SampleFont {mediumcondensed} \eTD \eTR
\bTR \bTD bold condensed    700/75  \eTD \bTD \SampleFont {boldcondensed}   \eTD \eTR
\bTR \bTD heavy condensed   900/75  \eTD \bTD \SampleFont {heavycondensed}  \eTD \eTR
\eTABLE

\stopsubject

\startbuffer[both]
\vfill
\startMPcode
  draw outlinetext.b
    ("\getbuffer[a]")
    (withcolor "white")
    (withcolor "red" withpen pencircle scaled 1/10)
    xsized .9TextWidth ;
\stopMPcode
\vfill
\startMPcode
  draw outlinetext.b
    ("\getbuffer[b]")
    (withcolor "white")
    (withcolor "red" withpen pencircle scaled 1/10)
    xsized .9TextWidth ;
\stopMPcode
\vfill
\startMPcode
  draw outlinetext.b
    ("\getbuffer[c]")
    (withcolor "white")
    (withcolor "red" withpen pencircle scaled 1/10)
    xsized .90TextWidth ;
\stopMPcode
\vfill
\stopbuffer

\startbuffer[fill]
\vfill
\startMPcode
  draw outlinetext.f
    ("\getbuffer[a]")
    (withcolor "white")
    xsized .9TextWidth ;
\stopMPcode
\vfill
\startMPcode
  draw outlinetext.f
    ("\getbuffer[b]")
    (withcolor "white")
    xsized .9TextWidth ;
\stopMPcode
\vfill
\startMPcode
  draw outlinetext.f
    ("\getbuffer[c]")
    (withcolor "white")
    xsized .9TextWidth ;
\stopMPcode
\vfill
\stopbuffer

\startbuffer[draw]
\vfill
\startMPcode
  draw outlinetext.d
    ("\getbuffer[a]")
    (withcolor "white" withpen pencircle scaled 1/10)
    xsized .9TextWidth ;
\stopMPcode
\vfill
\startMPcode
  draw outlinetext.d
    ("\getbuffer[b]")
    (withcolor "white" withpen pencircle scaled 1/10)
    xsized .9TextWidth ;
\stopMPcode
\vfill
\startMPcode
  draw outlinetext.d
    ("\getbuffer[c]")
    (withcolor "white" withpen pencircle scaled 1/10)
    xsized .9TextWidth ;
\stopMPcode
\vfill
\stopbuffer

\startbuffer[overlay]
\startoverlay{%
\startMPcode
  draw outlinetext.d
    ("\getbuffer[a]")
    (withcolor "green" withtransparency (3,0.5) withpen pencircle scaled 1/10)
    xsized .9TextWidth ;
\stopMPcode
}{%
\startMPcode
  draw outlinetext.d
    ("\getbuffer[b]")
    (withcolor "yellow" withtransparency (3,0.5) withpen pencircle scaled 1/10)
    xsized .9TextWidth ;
\stopMPcode
}{%
\startMPcode
  draw outlinetext.d
    ("\getbuffer[c]")
    (withcolor "red" withtransparency (3,0.5) withpen pencircle scaled 1/10)
    xsized .9TextWidth ;
\stopMPcode
}
\stopoverlay
\stopbuffer

\startbuffer[a]
\definedfont[name:adobevariablefontprototypeextralight]bachotex%
\stopbuffer

\startbuffer[b]
\definedfont[name:adobevariablefontprototypelight]bachotex%
\stopbuffer

\startbuffer[c]
\definedfont[name:adobevariablefontprototypebold]bachotex%
\stopbuffer

\startsubject[title=Metafontisch overlap (1)]
    \getbuffer[both]
\stopsubject

\startbuffer[a]
\definefontfeature[whatever][axis={weight:50}]%
\definedfont[name:adobevariablefontprototype*whatever]bachotex%
\stopbuffer

\startbuffer[b]
\definefontfeature[whatever][axis={weight:300}]%
\definedfont[name:adobevariablefontprototype*whatever]bachotex%
\stopbuffer

\startbuffer[c]
\definefontfeature[whatever][axis={weight:700}]%
\definedfont[name:adobevariablefontprototype*whatever]bachotex%
\stopbuffer

\startsubject[title=Metafontisch overlap (2)]
    \getbuffer[both]
\stopsubject
\startsubject[title=Fills hide the details]
    \getbuffer[fill]
\stopsubject
\startsubject[title=Unsuitable outlines]
    \getbuffer[draw]
\stopsubject

\startbuffer[a]
\definefontfeature[whatever][axis={weight:100,contrast:0}]%
\definedfont[name:adobevariablefontprototype*whatever]bachotex%
\stopbuffer

\startbuffer[b]
\definefontfeature[whatever][axis={weight:200,contrast:20}]%
\definedfont[name:adobevariablefontprototype*whatever]bachotex%
\stopbuffer

\startbuffer[c]
\definefontfeature[whatever][axis={weight:200,contrast:50}]%
\definedfont[name:adobevariablefontprototype*whatever]bachotex%
\stopbuffer

\startsubject[title=Stay within specification]
    \getbuffer[draw]
\stopsubject

\startsubject[title=Subjective choices]
    \getbuffer[fill]
\stopsubject

\startbuffer[a]
\definefontfeature[whatever][axis={weight:100,contrast:0}]%
\definedfont[name:adobevariablefontprototype*whatever]tex%
\stopbuffer

\startbuffer[b]
\definefontfeature[whatever][axis={weight:200,contrast:20}]%
\definedfont[name:adobevariablefontprototype*whatever]tex%
\stopbuffer

\startbuffer[c]
\definefontfeature[whatever][axis={weight:200,contrast:50}]%
\definedfont[name:adobevariablefontprototype*whatever]tex%
\stopbuffer

\startsubject[title=Difficult choices]
    \getbuffer[overlay]
\stopsubject

\startsubject[title=Definitions (1)]

\startbuffer
\definefontfeature
  [default:shaped]
  [default]
  [axis={width:10}]

\definefont
  [SomeFont]
  [file:avenirnextvariable*default:shaped]
\stopbuffer

\typebuffer \getbuffer

\start \setupinterlinespace \showglyphs \showfontkerns \SomeFont \input zapf \wordright{Hermann Zapf}\par \stop

\stopsubject

\startsubject[title=Definitions (2)]

\startbuffer
\definefontfeature
  [default:shaped]
  [default]
  [axis={width:100,weight=200}]

\definefont
  [SomeFont]
  [file:avenirnextvariable*default:shaped @ 12pt]
\stopbuffer

\typebuffer \getbuffer

\start \setupinterlinespace  \showglyphs \showfontkerns \SomeFont \input zapf \wordright{Hermann Zapf}\par \stop

\stopsubject

\startsubject[title=Transformations]

\subsubject{correction:}

\startformula
    x^\prime = x
             + s_{x1} \cdot x_1
             + s_{x2} \cdot x_2
             + s_{x3} \cdot x_3
             + s_{x4} \cdot x_4
\stopformula

\startformula
    y^\prime = y
             + s_{y1} \cdot y_1
             + s_{y2} \cdot y_2
             + s_{y3} \cdot y_3
             + s_{y4} \cdot y_4
\stopformula

\subsubject{internal cff:}

\starttyping
1 <setvstore>
120 [10 -30 40 -60] 1 <blend> ... <operator>
100 120 [10 -30 40 -60] [30 -10 -30 20] 2 <blend> .. <operator>
\stoptyping

\subsubject{external ttf:}

\starttyping
apply x deltas [10 -30 40 -60] to x 120
apply y deltas [30 -10 -30 20] to y 100
\stoptyping

\stopsubject

\startsubject[title=Follow up]

\startitemize
\startitem
    Performance is quite okay because we cache instances. I might come up with an
    alternative way but there is not much to gain.
\stopitem
\startitem
    Once fonts show up alternative interfaces to axis and scaling can be explored
    and provided.
\stopitem
\startitem
    I will look into ways to do all the backend font code in \CONTEXT\ in \LUA\
    (easier to update and more flexible).
\stopitem
\startitem
    Luigi and I will play with variable fonts defined in the traditional meta tools
    that come with \TEX.
\stopitem
\stopitemize

\stopsubject

\stopdocument