bachotex-2018-fonteffects.tex /size: 23 Kb    last modification: 2020-07-01 14:35
1% language=uk
2
3\definecolor[red]    [r=.6]
4\definecolor[green]  [g=.6]
5\definecolor[blue]   [b=.6]
6
7\definecolor[cyan]   [g=.6,b=.6]
8\definecolor[magenta][r=.6,b=.6]
9\definecolor[yellow] [r=.6,g=.6]
10
11\usemodule[abbreviations-smallcaps]
12\usemodule[scite]
13\usemodule[scite]
14
15\setuptyping[option=TEX]
16\setuptype[option=TEX]
17
18\dontcomplain
19
20\usebodyfont [modern]
21\usebodyfont[pagella]
22\usebodyfont [dejavu]
23
24\setuppapersize[S6]
25
26\definebodyfontenvironment[24pt]
27
28\definecolor[maincolor][r=.6]
29\definecolor[maintrans][r=.6,t=.5,a=1]
30\definecolor[moretrans][g=.6,t=.5,a=1]
31
32\setuplayout
33  [width=middle,
34   height=middle,
35   margin=0cm,
36   header=0cm,
37   footer=0cm,
38   topspace=1cm,
39   bottomspace=1cm,
40   backspace=1cm]
41
42\setupbackgrounds
43  [page]
44  [background=color,
45   backgroundcolor=darkgray]
46
47\setupbackgrounds
48  [text][text]
49  [background=color,
50   backgroundoffset=5mm,
51   backgroundcolor=middlegray]
52
53\definefontfeature[bbox][boundingbox=frame]
54
55\definefont
56  [LargeFont]
57  [SansBold*default,boldened-20,bbox @ 40pt]
58
59\definefont
60  [SmallFont]
61  [SansBold*default,boldened-20 @ 20pt]
62
63\definefont
64  [HeadFont]
65  [SansBold*default,boldened-30 @ 30pt]
66
67\setupbodyfont
68  [modernlatin,14.4pt]
69
70\setuphead
71  [title]
72  [style=\HeadFont,
73   color=maincolor,
74   align=middle]
75
76\definefontsynonym[BenchMark][lmroman10regular]
77
78\starttext
79
80\startstandardmakeup[footerstate=start]
81    \LargeFont \maincolor \setupalign[middle]
82    \vfil
83    \dontleavehmode\scale[width=.6\textwidth]{\setstrut\strut Modern}
84    \vfil
85    \dontleavehmode\scale[width=.8\textwidth]{\setstrut\strut Latin}
86    \vfil
87    \vfil
88    \SmallFont \darkgray Bacho\TeX\ 2018\enspace\emdash\enspace Hans Hagen
89\stopstandardmakeup
90
91\starttitle[title=Why oh why]
92
93\startitemize
94\startitem
95    In \CONTEXT\ we have a mechanism to apply effects to a glyph stream.
96\stopitem
97\startitem
98    An active user on the \CONTEXT\ mailing list wondered if that could be
99    applied to specific fonts.
100\stopitem
101\startitem
102    The particular interest concerned the possibility to bolden fonts.
103\stopitem
104\startitem
105    I don't really like effects and not all fonts are suitable for it.
106\stopitem
107\stopitemize
108
109\stoptitle
110
111\starttitle[title=What are effects]
112
113Normal effects are implemented using the \quote {effects} mechanism, which
114already dates way back in \MKII\ times and of course is also available for
115\MKIV.
116
117\defineeffect [inner]   [alternative=inner,rulethickness=1.25pt]
118\defineeffect [outer]   [alternative=outer,rulethickness=1.25pt]
119\defineeffect [both]    [alternative=both, rulethickness=1.25pt]
120\defineeffect [normal]  [alternative=normal]
121
122\starttyping
123\defineeffect
124  [outer]
125  [alternative=outer,
126   rulethickness=1.25pt]
127
128effect \starteffect[outer]effect\stopeffect
129\stoptyping
130
131\startlinecorrection
132
133    \definefont[DemoFont][BenchMark*default @ 70pt]
134
135    \scale[width=\textwidth]{\startcombination[3*2]
136      {\DemoFont\setstrut\strut\starteffect               [inner]effect\stopeffect}
137      {\startoverlay
138          {\DemoFont\setstrut\strut\maintrans \starteffect[inner]effect\stopeffect}
139          {\DemoFont\setstrut\strut\moretrans                    effect}
140       \stopoverlay}
141      {\DemoFont\setstrut\strut\starteffect               [outer]effect\stopeffect}
142      {\startoverlay
143          {\DemoFont\setstrut\strut\maintrans \starteffect[outer]effect\stopeffect}
144          {\DemoFont\setstrut\strut\moretrans                    effect}
145       \stopoverlay}
146      {\DemoFont\setstrut\strut\starteffect                [both]effect\stopeffect}
147      {\startoverlay
148          {\DemoFont\setstrut\strut\maintrans \starteffect [both]effect\stopeffect}
149          {\DemoFont\setstrut\strut\moretrans                    effect}
150       \stopoverlay}
151      {\startoverlay
152          {\DemoFont\setstrut\strut\moretrans                    effect}
153          {\DemoFont\setstrut\strut\maintrans \starteffect[inner]effect\stopeffect}
154       \stopoverlay}
155      {\tttf inner}
156      {\startoverlay
157          {\DemoFont\setstrut\strut\moretrans                    effect}
158          {\DemoFont\setstrut\strut\maintrans \starteffect[outer]effect\stopeffect}
159       \stopoverlay}
160      {\tttf outer}
161      {\startoverlay
162          {\DemoFont\setstrut\strut\moretrans                    effect}
163          {\DemoFont\setstrut\strut\maintrans \starteffect [both]effect\stopeffect}
164       \stopoverlay}
165      {\tttf both}
166    \stopcombination}
167
168\stoplinecorrection
169
170\stoptitle
171
172\starttitle[title=How tricky is this]
173
174\startitemize
175\startitem
176    Of course the only way to deal with this nicely is by using runtime created
177    virtual fonts.
178\stopitem
179\startitem
180    So called \PDF\ literals can interfere badly with font switches at the \PDF\
181    level and are therefore very inefficient.
182\stopitem
183\startitem
184    In order to properly support effects at the font level, we need to be able to
185    inject the right \PDF\ code in a more clever way.
186\stopitem
187\startitem
188    Two new keys were added to the font file definition table: \type{width} and
189    \type {mode}. When set these inject a \PDF\ line width operation and trigger the
190    right rendering mode (backend).
191\stopitem
192\stopitemize
193
194\stoptitle
195
196\starttitle[title=What interface do we need]
197
198\startbuffer
199\definefontfeature[effect-1][effect={width=0.8}]
200\definefontfeature[bbox]    [boundingbox=frame]
201
202\definefont
203  [EffectiveFont]
204  [BenchMark*default,effect-1,bbox @ 12pt]
205\stopbuffer
206
207\typebuffer \getbuffer
208
209\startlinecorrection[2*big]
210\scale[width=\textwidth]{\backgroundline[maincolor]{\EffectiveFont effective}}
211\stoplinecorrection
212
213\page
214
215\startbuffer
216\definefontfeature[effect-2][effect={width=1.1,wdelta=1.20}]
217\definefontfeature[effect-3][effect={width=1.1,wdelta=1.80}]
218
219\definefont
220  [EffectiveFontA]
221  [BenchMark*default,effect-2 @ 12pt]
222
223\definefont
224  [EffectiveFontB]
225  [BenchMark*default,effect-3 @ 12pt]
226\stopbuffer
227
228\typebuffer \getbuffer
229
230\scale[width=\textwidth]{\darkgray\showglyphs \EffectiveFontA effect \EffectiveFontB effect}
231
232\stoptitle
233
234\starttitle[title=Can we do better]
235
236\startitemize
237\startitem
238    This is still not good enough so next came playing with extended shapes. This is an
239    old feature inherited from \POSTSCRIPT\ times and \PDFTEX.
240\stopitem
241\startitem
242    The \LUATEX\ backend is very efficient with this kind of trickery and combines
243    it with font scaling.
244\stopitem
245\startitem
246    It was trivial to add a similar scaling in the vertical direction.
247\stopitem
248\stopitemize
249
250\page
251
252\startbuffer
253\definefontfeature[effect-4]
254  [effect={width=0.5,wdelta=1.5}]
255
256\definefontfeature[effect-5]
257  [effect={width=0.5,wdelta=1.5,extend=1.2}]
258
259\definefont
260  [EffectiveFontA]
261  [BenchMark*default,effect-4 @ 12pt]
262
263\definefont
264  [EffectiveFontB]
265  [BenchMark*default,effect-5 @ 12pt]
266\stopbuffer
267
268\typebuffer \getbuffer
269
270\startlinecorrection[2*big]
271\scale[width=\textwidth]{\darkgray\showglyphs \EffectiveFontA effect \EffectiveFontB effect}
272\stoplinecorrection
273
274\page
275
276\startbuffer
277\definefontfeature[effect-6]
278  [effect={width=0.5,wdelta=1.50}]
279
280\definefontfeature[effect-7]
281  [effect={width=0.5,wdelta=1.50,squeeze=1.2}]
282
283\definefont
284  [EffectiveFontA]
285  [BenchMark*default,effect-6 @ 12pt]
286
287\definefont
288  [EffectiveFontB]
289  [BenchMark*default,effect-7 @ 12pt]
290\stopbuffer
291
292\typebuffer \getbuffer
293
294\startlinecorrection[2*big]
295\scale[width=\textwidth]{\darkgray\showglyphs \EffectiveFontA effect \EffectiveFontB effect}
296\stoplinecorrection
297
298\stoptitle
299
300\starttitle[title=How about math]
301
302\startitemize
303\startitem
304    I never really needed this kind of trickery but it might be handy for
305    bold math in titles.
306\stopitem
307\startitem
308    But math is kind of special as it has extensibles, uses rules and is controlled
309    by math parameters.
310\stopitem
311\startitem
312    Math parameters are global for a formula so that doesn't work out well for mixed
313    families using fonts with different design parameters.
314\stopitem
315\stopitemize
316
317\page
318
319\starttyping
320\switchtobodyfont[modern]
321
322$\sqrt{\frac{\frac{1}{a}}{\frac{2}{b}}}$
323
324\switchtobodyfont[modernlatin]
325
326$\mr \sqrt{\frac{\frac{1}{a}}{\frac{2}{b}}}$
327$\mb \sqrt{\frac{\frac{1}{a}}{\frac{2}{b}}}$
328\stoptyping
329
330\startlinecorrection
331\startcombination[3*1]
332    {\maincolor\switchtobodyfont     [modern]\scale[height=.25\textwidth]{$\sqrt{\frac{\frac{1}{a}}{\frac{2}{b}}}$}} {\tttf latinmodern}
333    {\maincolor\switchtobodyfont[modernlatin]\scale[height=.25\textwidth]{$\sqrt{\frac{\frac{1}{a}}{\frac{2}{b}}}$}} {\tttf modernlatin}
334    {\maincolor\switchtobodyfont[modernlatin]\scale[height=.25\textwidth]{$\sqrt{\frac{\frac{1}{a}}{\frac{2}{b}}}$}} {\tttf modernlatin}
335\stopcombination
336\stoplinecorrection
337
338\stoptitle
339
340\starttitle[title=Is it useful]
341
342\startitemize
343\startitem
344    \start \definedfont[BenchMark*default]%
345    For reading on a different medium than paper a bit bolder font often
346    works better. This is a normal Latin Modern.\stop
347\stopitem
348\startitem
349    Here we use the \type {modernlatin} For reading on a different medium than
350    paper a bit bolder font often works better.
351\stopitem
352\startitem
353    In my opinion a slightly bolder Latin Modern looks a bit more modern, but
354    that's of course just an opinion.
355\stopitem
356\startitem
357    I'm not sure if and when I will use this new trickery; maybe to compensate the
358    lack of bold math fonts.
359\stopitem
360\startitem
361    Performance wise there is no penalty. File don't get larger. Rendering seems to
362    be somewhat slower.
363\stopitem
364\startitem
365    In the end it's probably just another example of feature creep or \TEX\ hobbyism.
366\stopitem
367\stopitemize
368
369\stoptitle
370
371\starttitle[title=Kerning]
372
373\startMPinclusions
374    def SampleShapes(expr dx, offset, pw, k) =
375        picture p ; p := image (
376            draw               fullcircle scaled 1cm                   withcolor "maincolor" ;
377            draw               fullsquare scaled 1cm  shifted (dx+k,0) withcolor "maincolor" ;
378            draw point 8   of (fullcircle scaled 1cm)                  withcolor white ;
379            draw point 3.5 of (fullsquare scaled 1cm) shifted (dx+k,0) withcolor white ;
380        ) shifted (offset,0) ;
381        draw p withpen pencircle scaled pw ;
382        draw boundingbox p withcolor white ;
383    enddef ;
384\stopMPinclusions
385
386\startitemize
387\startitem
388    To what extent do we need to compensate dimensions in order to get the kerning
389    acceptable.
390\stopitem
391\startitem
392    Messing around with font features is fragile because there is not much consistency in
393    how these are organized.
394\stopitem
395\stopitemize
396
397\startlinecorrection[2*big]
398\startMPcode
399    SampleShapes(15mm,  0mm,1mm,0mm) ;
400    SampleShapes(15mm, 40mm,2mm,0mm) ;
401    SampleShapes(17mm, 80mm,2mm,0mm) ;
402\stopMPcode
403\stoplinecorrection
404
405\startlinecorrection[2*big]
406\startMPcode
407    SampleShapes(15mm,  0mm,1mm,0mm) ;
408    SampleShapes(15mm, 40mm,2mm,2mm) ;
409    SampleShapes(17mm, 80mm,2mm,2mm) ;
410\stopMPcode
411\stoplinecorrection
412
413\startlinecorrection[2*big]
414\startMPcode
415    SampleShapes(10mm,  0mm,1mm,0mm) ;
416    SampleShapes(10mm, 40mm,1mm,1mm) ;
417    SampleShapes(10mm, 80mm,2mm,0mm) ;
418    SampleShapes(10mm,120mm,2mm,2mm) ;
419\stopMPcode
420\stoplinecorrection
421
422\stoptitle
423
424\starttitle[title=Ligatures]
425
426\definefontfeature
427  [demo-1]
428  [default]
429  [hlig=yes]
430
431\definefontfeature
432  [demo-2]
433  [demo-1]
434  [effect=0.5]
435
436\startitemize
437\startitem
438    Ligatures are even less predictable so this is why we cannot apply too much
439    effect.
440\stopitem
441\startitem
442    There can be artifacts due to the way characters are combined (like in Latin
443    Modern).
444\stopitem
445\stopitemize
446
447\startlinecorrection
448\startcombination[1*3]
449    { \scale [width=.8\textwidth] {
450        \definedfont[texgyrepagellaregular*demo-1]fist effe
451        \par
452        \definedfont[texgyrepagellaregular*demo-2]fist effe
453    } } {
454        \tttf \maincolor texgyre pagella regular
455    } { \scale [width=.8\textwidth] {
456        \definedfont[cambria*demo-1]fist effe
457        \par
458        \definedfont[cambria*demo-2]fist effe
459    } } {
460        \tttf \maincolor cambria
461    } { \scale [width=.8\textwidth] {
462        \definedfont[ebgaramond12regular*demo-1]fist effe
463        \par
464        \definedfont[ebgaramond12regular*demo-2]fist effe
465    } } {
466        \tttf \maincolor ebgaramond 12 regular
467    }
468\stopcombination
469\stoplinecorrection
470
471\stoptitle
472
473\starttitle[title=Finetuning]
474
475\startbuffer
476\definefontfeature[lm-bald]
477  [effect={width=0.25,effect=both}]
478\definefontfeature[pg-bald]
479  [effect={width=0.25,effect=both}]
480\definefontfeature[dj-bald]
481  [effect={width=0.35,effect=both}]
482
483\definefontfeature[lm-bold]
484  [effect={width=0.25,hdelta=0,ddelta=0,effect=both,
485    extend=1.10}]
486
487\definefontfeature[pg-bold]
488  [effect={width=0.25,hdelta=0,ddelta=0,effect=both,
489    extend=1.00}]
490
491\definefontfeature[dj-bold]
492  [effect={width=0.35,hdelta=0,ddelta=0,effect=both,
493    extend=1.05}]
494\stopbuffer
495
496\definefont[lmbald][Serif*default,lm-bald sa d]
497\definefont[pgbald][Serif*default,pg-bald sa d]
498\definefont[djbald][Serif*default,dj-bald sa d]
499
500\definefont[lmbold][Serif*default,lm-bold sa d]
501\definefont[pgbold][Serif*default,pg-bold sa d]
502\definefont[djbold][Serif*default,dj-bold sa d]
503
504\typebuffer \getbuffer
505
506\page
507
508\starttabulate[|l|l|l|l|]
509\NC
510    \NC
511    \tt \maincolor modern  \NC
512    \tt \maincolor pagella \NC
513    \tt \maincolor dejavu  \NC
514\NR
515\NC
516    \maincolor \type{\tfd} \NC
517    \switchtobodyfont [modern,24pt]\strut\ruledhbox{\tfd    ABC}\NC
518    \switchtobodyfont[pagella,24pt]\strut\ruledhbox{\tfd    ABC}\NC
519    \switchtobodyfont [dejavu,24pt]\strut\ruledhbox{\tfd    ABC}\NC
520\NR
521\NC
522    \maincolor \type{\..bald} \NC
523    \switchtobodyfont [modern,24pt]\strut\ruledhbox{\lmbald ABC}\NC
524    \switchtobodyfont[pagella,24pt]\strut\ruledhbox{\pgbald ABC}\NC
525    \switchtobodyfont [dejavu,24pt]\strut\ruledhbox{\djbald ABC}\NC
526\NR
527\NC
528    \maincolor \type{\bfd} \NC
529    \switchtobodyfont [modern,24pt]\strut\ruledhbox{\bfd    ABC}\NC
530    \switchtobodyfont[pagella,24pt]\strut\ruledhbox{\bfd    ABC}\NC
531    \switchtobodyfont [dejavu,24pt]\strut\ruledhbox{\bfd    ABC}\NC
532\NR
533\NC
534    \maincolor \type{\..bold} \NC
535    \switchtobodyfont [modern,24pt]\strut\ruledhbox{\lmbold ABC}\NC
536    \switchtobodyfont[pagella,24pt]\strut\ruledhbox{\pgbold ABC}\NC
537    \switchtobodyfont [dejavu,24pt]\strut\ruledhbox{\djbold ABC}\NC
538\NR
539\stoptabulate
540
541\stoptitle
542
543\starttitle[title=Pagella]
544
545\startbuffer
546\definefontfeature
547  [pg-fake-1]
548  [effect={width=0.25,effect=both}]
549
550\definefontfeature
551  [pg-fake-2]
552  [effect={width=0.25,hdelta=0,ddelta=0,effect=both}]
553
554\definefont[pgregular]  [Serif*default]
555\definefont[pgbold]     [SerifBold*default]
556\definefont[pgfakebolda][Serif*default,pg-fake-1]
557\definefont[pgfakeboldb][Serif*default,pg-fake-2]
558
559\definecolor[color-pgregular]  [t=.5,a=1,r=.6]
560\definecolor[color-pgbold]     [t=.5,a=1,g=.6]
561\definecolor[color-pgfakebolda][t=.5,a=1,b=.6]
562\definecolor[color-pgfakeboldb][t=.5,a=1,r=.6,g=.6]
563\stopbuffer
564
565\typebuffer
566
567\page
568
569\startbuffer[sample]
570
571\start \switchtobodyfont[pagella]  \getbuffer
572
573\startcombination[2*2]
574    {
575        \scale [width=\measure{combination}] {
576            \ruledhbox{\showglyphs\pgregular   \SampleWord}
577        }
578    } {
579        regular
580    } {
581        \scale [width=\measure{combination}] {
582            \ruledhbox{\showglyphs\pgbold      \SampleWord}
583        }
584    } {
585        bold
586    } {
587        \scale [width=\measure{combination}] {
588            \ruledhbox{\showglyphs\pgfakebolda \SampleWord}
589        }
590    } {
591        fakebolda
592    } {
593        \scale [width=\measure{combination}] {
594            \ruledhbox{\showglyphs\pgfakeboldb \SampleWord}
595        }
596    } {
597        fakeboldb
598    }
599\stopcombination
600
601\stop
602
603\page
604
605\start \switchtobodyfont[pagella]  \getbuffer
606
607\startcombination[2*3]
608    {
609        \scale [width=.35\textwidth] {
610            \startoverlay
611                {\color[color-pgregular]  {\pgregular   \SampleWord}}
612                {\color[color-pgbold]     {\pgbold      \SampleWord}}
613            \stopoverlay
614        }
615    } {
616        bold over regular
617    } {
618        \scale [width=.35\textwidth] {
619            \startoverlay
620                {\color[color-pgregular]  {\pgregular   \SampleWord}}
621                {\color[color-pgfakeboldb]{\pgfakeboldb \SampleWord}}
622            \stopoverlay
623        }
624    } {
625        fakebolda over regular
626    } {
627        \scale [width=.35\textwidth] {
628            \startoverlay
629                {\color[color-pgregular]  {\pgregular   \SampleWord}}
630                {\color[color-pgfakebolda]{\pgfakeboldb \SampleWord}}
631            \stopoverlay
632        }
633    } {
634        fakeboldb over regular
635    } {
636        \scale [width=.35\textwidth] {
637            \startoverlay
638                {\color[color-pgbold]     {\pgbold      \SampleWord}}
639                {\color[color-pgfakeboldb]{\pgfakeboldb \SampleWord}}
640            \stopoverlay
641        }
642    } {
643        fakeboldb over bold
644    } {
645        \scale [width=.35\textwidth] {
646            \startoverlay
647                {\color[color-pgfakebolda]{\pgfakebolda \SampleWord}}
648                {\color[color-pgfakeboldb]{\pgfakeboldb \SampleWord}}
649            \stopoverlay
650        }
651    } {
652         fakeboldb over fakebolda
653    } {
654        \scale [width=.35\textwidth] {
655            \startoverlay
656                {\color[color-pgregular]  {\pgregular   \SampleWord}}
657                {\color[color-pgbold]     {\pgbold      \SampleWord}}
658                {\color[color-pgfakebolda]{\pgfakebolda \SampleWord}}
659                {\color[color-pgfakeboldb]{\pgfakeboldb \SampleWord}}
660            \stopoverlay
661        }
662    } {
663         all four overlayed
664    }
665\stopcombination
666
667\stop
668
669\stopbuffer
670
671\def\SampleWord{\^o\"ep\c s}    \getbuffer[sample]
672\def\SampleWord{London Grammar} \getbuffer[sample]
673
674\stoptitle
675
676\starttitle[title=Arabic]
677
678\startbuffer
679\definefontfeature
680  [bolden-arabic-1]
681  [effect={width=0.4}]
682
683\definefontfeature
684  [bolden-arabic-2]
685  [effect={width=0.4,effect=outer}]
686
687\definefontfeature
688  [bolden-arabic-3]
689  [effect={width=0.5,wdelta=0.5,ddelta=.2,hdelta=.2,factor=.1}]
690\stopbuffer
691
692\typebuffer \getbuffer
693
694\startbuffer
695
696\setupalign
697  [righttoleft]
698
699\setupinterlinespace
700  [1.5]
701
702\start
703  \definedfont[arabictest*arabic,bolden-arabic-1 @ 30pt]
704  \samplefile{khatt-ar}\blank
705  \definedfont[arabictest*arabic,bolden-arabic-2 @ 30pt]
706  \samplefile{khatt-ar}\blank
707  \definedfont[arabictest*arabic,bolden-arabic-3 @ 30pt]
708  \samplefile{khatt-ar}\blank
709\stop
710\stopbuffer
711
712\page \start \definefontsynonym[arabictest][arabtype] \getbuffer\stop
713
714\page \start \definefontsynonym[arabictest][husayni]  \getbuffer\stop
715
716\stoptitle
717
718\starttitle[title=Marks and cursive]
719
720\startitemize
721\startitem
722    Marks are tricky because they can be anchored at any location and we can
723    only guess what should be done.
724\stopitem
725\startitem
726    Cursive connections still need to connect and we don't know in advance
727    how shapes overlap.
728\stopitem
729\stopitemize
730
731\startMPinclusions
732    def DrawShapes(expr how) =
733        def SampleShapes(expr offset, pw, xc, xs, xt, yc, ys, yt, txt, more) =
734            numeric l ; l := pw * mm ;
735            picture p ; p := image (
736                draw fullcircle   scaled 10 ;
737                draw fullcircle   scaled  3 shifted (-3+xc  ,8+yc) withcolor "darkred" ;
738                draw fullsquare   scaled  3 shifted ( 6+xs  ,7+ys) withcolor "darkblue";
739                draw fulltriangle scaled  4 shifted ( 6+xt+5,6+yt) withcolor "darkgreen";
740            ) shifted (offset,0) scaled mm ;
741            draw p
742                withpen pencircle
743                    if how = 2 :
744                        xscaled l yscaled (l/2) rotated 30 ;
745                    else :
746                        scaled l ;
747                    fi ;
748            draw boundingbox p
749                withcolor "darkyellow" ;
750            draw textext(txt)
751                shifted (xpart center p, -8mm) ;
752            draw textext(more)
753                shifted (xpart center p, -11mm) ;
754        enddef ;
755        SampleShapes(  0,1, 0,0,0, 0,   0,   0,  "\tinyfont \setstrut \strut original",   "\tinyfont \setstrut \strut ") ;
756        SampleShapes( 25,2, 0,0,0, 0,   0,   0,  "\tinyfont \setstrut \strut instance",   "\tinyfont \setstrut \strut ") ;
757        SampleShapes( 50,2,-1,1,0, 0,   0,   0,  "\tinyfont \setstrut \strut mark",       "\tinyfont \setstrut \strut x only") ;
758        SampleShapes( 75,2,-1,1,1, 0,   0,   0,  "\tinyfont \setstrut \strut mark + mkmk","\tinyfont \setstrut \strut x only") ;
759        SampleShapes(100,2,-1,1,1, 1,   1,   1,  "\tinyfont \setstrut \strut mark + mkmk","\tinyfont \setstrut \strut x and y") ;
760        SampleShapes(125,2,-1,2,2,-1/2,-1/2,-1/2,"\tinyfont \setstrut \strut mark + mkmk","\tinyfont \setstrut \strut x and -y") ;
761    enddef ;
762\stopMPinclusions
763
764\startlinecorrection[2*big]
765\scale
766  [width=\textwidth]
767  {\startMPcode DrawShapes(1) ; \stopMPcode}
768\stoplinecorrection
769
770\startlinecorrection[2*big]
771\scale
772  [width=\textwidth]
773  {\startMPcode DrawShapes(2) ; \stopMPcode}
774\stoplinecorrection
775
776\stoptitle
777
778\starttitle[title=Radicals and such]
779
780Radicals are constructed using rules and extensible characters. Especially the rules
781need to be adapted.
782
783\startbuffer[mathblob]
784\def\MathSample
785  {2\times\sqrt{\frac{\sqrt{\frac{\sqrt{2}}{\sqrt{2}}}}
786     {\sqrt{\frac{\sqrt{2}}{\sqrt{2}}}}}}
787\stopbuffer
788
789\startbuffer
790$\mr \darkblue  \MathSample \quad
791 \mb \darkgreen \MathSample $
792\stopbuffer
793
794\getbuffer[mathblob]
795
796\typebuffer
797
798\startlinecorrection[blank]
799\scale[width=\textwidth]{\switchtobodyfont[modernlatin,24pt]\getbuffer}
800\stoplinecorrection
801
802\page
803
804\startbuffer
805\dostepwiserecurse {1} {30} {5} {
806  $
807    \mr \sqrt{\blackrule[width=2mm,height=#1mm,color=darkblue]}
808    \quad
809    \mb \sqrt{\blackrule[width=2mm,height=#1mm,color=darkgreen]}
810  $
811}
812\stopbuffer
813
814\typebuffer
815
816\startlinecorrection[blank]
817\scale[width=\textwidth]{\switchtobodyfont[modernlatin,24pt]\getbuffer}
818\stoplinecorrection
819
820\page
821
822\definecolor[colormr] [t=.5,a=1,b=.6]
823\definecolor[colormb] [t=.5,a=1,g=.6]
824
825% and a fix in \LUATEX: pickup the value from the font instead of the currently
826
827\startlinecorrection
828\midaligned{\scale[height=.6\textheight]{\startoverlay
829    {\color[colormb]{$\mb\sqrt{\frac{1}{x}}$}}
830    {\color[colormr]{$   \sqrt{\frac{1}{x}}$}}
831\stopoverlay}}
832\stoplinecorrection
833
834\page
835
836\unexpanded\def\ShowMathSample#1%
837  {\switchtobodyfont[#1,14.4pt]%
838   \mathematics{%
839    \mr \darkblue  \MathSample \quad
840    \mb \darkgreen \MathSample
841   }}
842
843\unexpanded\def\ShowMathCaption#1%
844  {\switchtobodyfont[#1]%
845   #1:
846   $
847   {\mr2\enspace \scriptstyle2\enspace \scriptscriptstyle2}
848   \enspace
849   {\mb2\enspace \scriptstyle2\enspace \scriptscriptstyle2}
850   $}
851
852\midaligned{\startcombination[3*2]
853    {\ShowMathSample {dejavu}} {\ShowMathCaption{dejavu}}
854    {\ShowMathSample{pagella}} {\ShowMathCaption{pagella}}
855    {\ShowMathSample {termes}} {\ShowMathCaption{termes}}
856    {\ShowMathSample  {bonum}} {\ShowMathCaption{bonum}}
857    {\ShowMathSample {schola}} {\ShowMathCaption{schola}}
858    {\ShowMathSample{cambria}} {\ShowMathCaption{cambria}}
859\stopcombination}
860
861\page
862
863\starttyping
864\definefontfeature
865  [boldened-30]
866  [effect={width=0.3,extend=1.15,squeeze=0.985,%
867    delta=1,hdelta=0.225,ddelta=0.225,vshift=0.225}]
868
869\definefontfeature
870  [boldened-30]
871  [effect={width=0.30,auto=yes}]
872\stoptyping
873
874\stoptitle
875
876\starttitle[title=An application]
877
878\def\MathSample
879  {\overbrace{2 +
880     \sqrt{\frac{\sqrt{\frac{\sqrt{2}}{\sqrt{2}}}}
881       {\sqrt{\frac{\sqrt{\underbar{2}}}{\sqrt{\overbar{2}}}}}}}}
882
883\startbuffer
884\definehead [mysectiona] [section]
885\definehead [mysectionb] [mysectiona]
886
887\setuphead
888  [mysectiona]
889  [style=\tfc,
890   color=darkblue,
891   before=\blank,
892   after=\blank]
893
894\setuphead
895  [mysectionb]
896  [style=\bfc,
897   color=darkred]
898
899\mysectiona{Regular\quad$\MathSample\quad\mb\MathSample$}
900\mysectionb{Bold   \quad$\MathSample\quad\mb\MathSample$}
901\stopbuffer
902
903\typebuffer \page \getbuffer \page
904
905\startcolumns
906    \switchtobodyfont[modern,12pt]      \setupinterlinespace[15pt] \samplefile{poe} \column
907    \switchtobodyfont[modernlatin,12pt] \setupinterlinespace[15pt] \samplefile{poe} % \column
908\stopcolumns
909
910\stoptitle
911
912\stoptext
913