summaryrefslogtreecommitdiff
path: root/doc/context/presentations/context/2020/context-2020-mp.tex
blob: 6d2f640fb034710c0830e641c61d9cffab37b400 (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
% language=us

\usemodule[present-boring,abbreviations-logos]

\startdocument
  [title={METAFUN},
   banner={simple fonts},
   location={context\enspace {\bf 2020}\enspace meeting}]

\starttitle[title=Metafonts]

\startitemize

\startitem
    Because \METAPOST\ is based on \METAFONT\ it make sense to use of for making fonts.
\stopitem

\startitem
    Making a font is an art in itself, something that is actually proven by many bad
    looking fonts, but we have plenty of choice nowadays.
\stopitem

\startitem
    We tend to use free fonts and often being made by volunteers we can hardly have any
    demands.
\stopitem

\startitem
    So, instead of complaining (which is not nice anyway) we can try to (at least temporary)
    come up with a solution ourselves.
\stopitem

\startitem
    We're actually talking about missing glyphs here and \METAPOST\ can be of help.
\stopitem

\startitem
    Also keep in mind that we always had this option or variants of it in \CONTEXT, it's
    just that we can make nicer interfaces now.
\stopitem

\startitem
    So, don't expect something spectacular.
\stopitem

\stopitemize

\stoptitle

\starttitle[title=What is is not]

Years ago mechanisms were added to \MKIV\ to come up with more fancy shapes in
for instance math. Actually Alan needed it and I wanted a root symbol to look
like school times.

\startbuffer
\useMPlibrary[mat]

\setupmathradical[color=darkgray,alternative=mp]

% \definemathradical [sqrt] [mp=minifun::math:radical:default]
\stopbuffer

\typebuffer \getbuffer

So:

\startbuffer
\scale[height=2cm]{$ \sqrt {a+b+c+d} $}
\stopbuffer

\typebuffer

Gives:

\startlinecorrection
\getbuffer
\stoplinecorrection

\page

And with:

\startbuffer
\startuniqueMPgraphic{minifun::math:radical:default}
draw
    math_radical_simple(OverlayWidth,OverlayHeight,OverlayDepth,OverlayOffset)
    withpen pencircle
        xscaled (2OverlayLineWidth)
        yscaled (1OverlayLineWidth/4)
        rotated 30
    dashed evenly
    withcolor OverlayLineColor ;
\stopuniqueMPgraphic
\stopbuffer

\typebuffer

We get

\startlinecorrection
\getbuffer
\scale[height=2cm]{$ \sqrt {a+b+c+d} $}
\stoplinecorrection

\page

Also think of stackers:

\startbuffer
\setupmathstackers [both]   [color=darkgray,alternative=mp]
\setupmathstackers [top]    [color=darkgray,alternative=mp]
\setupmathstackers [bottom] [color=darkgray,alternative=mp]
\stopbuffer

\typebuffer \getbuffer

\blank[2*line]

\startbuffer
$
    \overbracket   {a+b+c+d} \quad
    \underbracket  {a+b+c+d} \quad
    \doublebracket {a+b+c+d}
$
\blank
$
    \overparent   {a+b+c+d} \quad
    \underparent  {a+b+c+d} \quad
    \doubleparent {a+b+c+d}
$
\blank
$
    \overbrace   {a+b+c+d} \quad
    \underbrace  {a+b+c+d} \quad
    \doublebrace {a+b+c+d}
$
\blank
$
    \overbar   {a+b+c+d} \quad
    \underbar  {a+b+c+d} \quad
    \doublebar {a+b+c+d}
$
\blank
$
    \overleftarrow  {a+b+c+d} \quad
    \overrightarrow {a+b+c+d}
$
\blank
$
    \underleftarrow  {a+b+c+d} \quad
    \underrightarrow {a+b+c+d}
$
\stopbuffer

\getbuffer

\blank[2*line]

But, these are just overlays and nothing special: we simply don't use the normal
font route not fancy \LUA\ tricks either (in principle \MKII\ could do this). I
might upgrade it some day (no real demand so far, just fun stuff).

\stoptitle

\starttitle[title=Real fonts]

\startitemize

\startitem For text we need an efficient way to define extra shapes. \stopitem
\startitem We don't really want inline graphics every time we use a glyph. \stopitem
\startitem We also want to cut and paste properly. \stopitem
\startitem Basically the fact that we drop in shapes should be hidden. \stopitem

\blank[2*line]

\startitem
    We use the same (generic) subsystem that is also used for color fonts, bitmap
    emoji, \SVG\ fonts, etc.
\stopitem
\startitem
    Shapes end up as \TYPETHREE\ fonts. These have some specific properties and
    limitations, but we can actually make \UNICODE\ fonts.
\stopitem
\startitem
    The system is not burdened by much overhead and most happens at embedding time.
\stopitem

\stopitemize

\page

\startbuffer[font]
\definefont[DemoFontA][Serif*default @ 10pt]
\definefont[DemoFontB][Serif*default @ 12pt]
\definefont[DemoFontC][Serif*default @ 14pt]
\definefont[DemoFontD][SerifBold*default @ 14pt]
\stopbuffer

\typebuffer[font] \getbuffer[font]

\startbuffer[demo]
\startlines
\DemoFontA first\endash second\emdash third\char"2015\relax fourth
\DemoFontB first\endash second\emdash third\char"2015\relax fourth
\DemoFontC first\endash second\emdash third\char"2015\relax fourth
\DemoFontD first\endash second\emdash third\char"2015\relax fourth
\stoplines
\stopbuffer

\typebuffer[demo] \getbuffer[demo]

\page

\startbuffer[mpone]
\startMPcalculation{simplefun}

    vardef QuotationDashOne =
        draw image (
            interim linecap := squared ;
            save l ; l := 0.2 ;
            draw (l/2,3) -- (10-l/2,3) withpen pencircle scaled l ;
        )
    enddef ;

    lmt_registerglyphs [
        name     = "symbolsone",
        units    = 10,
        usecolor = true,
        width    = 10,
        height   = 3.1,
        depth    = 0,
    ] ;

    lmt_registerglyph [
        category = "symbolsone",
        unicode  = "0x2015",
        code     = "QuotationDashOne ;"
    ] ;

\stopMPcalculation
\stopbuffer

\getbuffer[mpone]

\startbuffer[font]
\definefontfeature[exampleone][metapost=symbolsone]

\definefont[DemoFontA][Serif*default,exampleone @ 10pt]
\definefont[DemoFontB][Serif*default,exampleone @ 12pt]
\definefont[DemoFontC][Serif*default,exampleone @ 14pt]
\definefont[DemoFontD][SerifBold*default,exampleone @ 14pt]
\stopbuffer

\typebuffer[font] \getbuffer[font]

\getbuffer[demo]

\page

\typebuffer[mpone][style=\tt\small\small]

\page

\startbuffer[mptwo]
\startMPcalculation{simplefun}

    vardef QuotationDashTwo =
        draw image (
            interim linecap := squared ;
            save l ; l := 0.4 ;
            string weight ; weight := getparameter "mpsfont" "parentdata" "shared" "rawdata" "metadata" "weight" ;
            if     weight = "semibold" : l := l * 2;
            elseif weight = "bold"     : l := l * 3; fi
            draw (l/2,3) -- (10-l/2,3) withpen pencircle scaled l
            withcolor yellow ;
        )
    enddef ;

    lmt_registerglyphs [
        name     = "symbolstwo",
        units    = 10,
        usecolor = false,
        width    = 10,
        height   = 3.1,
        depth    = 0,
    ] ;

    lmt_registerglyph [
        category = "symbolstwo",
        unicode  = "0x2015",
        code     = "QuotationDashTwo ;"
    ] ;

\stopMPcalculation
\stopbuffer

\getbuffer[mptwo]

\startbuffer[font]
\definefontfeature[exampletwo][metapost=symbolstwo]

\definefont[DemoFontA][Serif*default,exampletwo @ 10pt]
\definefont[DemoFontB][Serif*default,exampletwo @ 12pt]
\definefont[DemoFontC][Serif*default,exampletwo @ 14pt]
\definefont[DemoFontD][SerifBold*default,exampletwo @ 14pt]
\stopbuffer

\typebuffer[font] \getbuffer[font]

\getbuffer[demo]

\page

\typebuffer[mptwo][style=\tt\small\small]

\stoptitle

\starttitle[title=More examples]

We give some examples (these are also in the modules). Overloading math
symbols:

\starttyping
meta-imp-kindergarten.mkxl
\stoptyping

Extending fonts with Don Knuths dices and tiles (symbols, ligatures, proper
\UNICODE):

\starttyping
meta-imp-gamesymbols.mkxl
\stoptyping

An implementation of Don Knuths ThirtySix font in various variants (color,
random, shapes):

\starttyping
meta-imp-threesix.mkxl
\stoptyping

\stopdocument