summaryrefslogtreecommitdiff
path: root/doc/context/presentations/bachotex/2018/bachotex-2018-fonteffects.tex
blob: 330fc3340ccee321102d14a20e6c56960f70897d (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
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
% language=uk

\definecolor[red]    [r=.6]
\definecolor[green]  [g=.6]
\definecolor[blue]   [b=.6]

\definecolor[cyan]   [g=.6,b=.6]
\definecolor[magenta][r=.6,b=.6]
\definecolor[yellow] [r=.6,g=.6]

\usemodule[abbreviations-smallcaps]
\usemodule[scite]
\usemodule[scite]

\setuptyping[option=TEX]
\setuptype[option=TEX]

\dontcomplain

\usebodyfont [modern]
\usebodyfont[pagella]
\usebodyfont [dejavu]

\setuppapersize[S6]

\definebodyfontenvironment[24pt]

\definecolor[maincolor][r=.6]
\definecolor[maintrans][r=.6,t=.5,a=1]
\definecolor[moretrans][g=.6,t=.5,a=1]

\setuplayout
  [width=middle,
   height=middle,
   margin=0cm,
   header=0cm,
   footer=0cm,
   topspace=1cm,
   bottomspace=1cm,
   backspace=1cm]

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

\setupbackgrounds
  [text][text]
  [background=color,
   backgroundoffset=5mm,
   backgroundcolor=middlegray]

\definefontfeature[bbox][boundingbox=frame]

\definefont
  [LargeFont]
  [SansBold*default,boldened-20,bbox @ 40pt]

\definefont
  [SmallFont]
  [SansBold*default,boldened-20 @ 20pt]

\definefont
  [HeadFont]
  [SansBold*default,boldened-30 @ 30pt]

\setupbodyfont
  [modernlatin,14.4pt]

\setuphead
  [title]
  [style=\HeadFont,
   color=maincolor,
   align=middle]

\definefontsynonym[BenchMark][lmroman10regular]

\starttext

\startstandardmakeup[footerstate=start]
    \LargeFont \maincolor \setupalign[middle]
    \vfil
    \dontleavehmode\scale[width=.6\textwidth]{\setstrut\strut Modern}
    \vfil
    \dontleavehmode\scale[width=.8\textwidth]{\setstrut\strut Latin}
    \vfil
    \vfil
    \SmallFont \darkgray Bacho\TeX\ 2018\enspace\emdash\enspace Hans Hagen
\stopstandardmakeup

\starttitle[title=Why oh why]

\startitemize
\startitem
    In \CONTEXT\ we have a mechanism to apply effects to a glyph stream.
\stopitem
\startitem
    An active user on the \CONTEXT\ mailing list wondered if that could be
    applied to specific fonts.
\stopitem
\startitem
    The particular interest concerned the possibility to bolden fonts.
\stopitem
\startitem
    I don't really like effects and not all fonts are suitable for it.
\stopitem
\stopitemize

\stoptitle

\starttitle[title=What are effects]

Normal effects are implemented using the \quote {effects} mechanism, which
already dates way back in \MKII\ times and of course is also available for
\MKIV.

\defineeffect [inner]   [alternative=inner,rulethickness=1.25pt]
\defineeffect [outer]   [alternative=outer,rulethickness=1.25pt]
\defineeffect [both]    [alternative=both, rulethickness=1.25pt]
\defineeffect [normal]  [alternative=normal]

\starttyping
\defineeffect
  [outer]
  [alternative=outer,
   rulethickness=1.25pt]

effect \starteffect[outer]effect\stopeffect
\stoptyping

\startlinecorrection

    \definefont[DemoFont][BenchMark*default @ 70pt]

    \scale[width=\textwidth]{\startcombination[3*2]
      {\DemoFont\setstrut\strut\starteffect               [inner]effect\stopeffect}
      {\startoverlay
          {\DemoFont\setstrut\strut\maintrans \starteffect[inner]effect\stopeffect}
          {\DemoFont\setstrut\strut\moretrans                    effect}
       \stopoverlay}
      {\DemoFont\setstrut\strut\starteffect               [outer]effect\stopeffect}
      {\startoverlay
          {\DemoFont\setstrut\strut\maintrans \starteffect[outer]effect\stopeffect}
          {\DemoFont\setstrut\strut\moretrans                    effect}
       \stopoverlay}
      {\DemoFont\setstrut\strut\starteffect                [both]effect\stopeffect}
      {\startoverlay
          {\DemoFont\setstrut\strut\maintrans \starteffect [both]effect\stopeffect}
          {\DemoFont\setstrut\strut\moretrans                    effect}
       \stopoverlay}
      {\startoverlay
          {\DemoFont\setstrut\strut\moretrans                    effect}
          {\DemoFont\setstrut\strut\maintrans \starteffect[inner]effect\stopeffect}
       \stopoverlay}
      {\tttf inner}
      {\startoverlay
          {\DemoFont\setstrut\strut\moretrans                    effect}
          {\DemoFont\setstrut\strut\maintrans \starteffect[outer]effect\stopeffect}
       \stopoverlay}
      {\tttf outer}
      {\startoverlay
          {\DemoFont\setstrut\strut\moretrans                    effect}
          {\DemoFont\setstrut\strut\maintrans \starteffect [both]effect\stopeffect}
       \stopoverlay}
      {\tttf both}
    \stopcombination}

\stoplinecorrection

\stoptitle

\starttitle[title=How tricky is this]

\startitemize
\startitem
    Of course the only way to deal with this nicely is by using runtime created
    virtual fonts.
\stopitem
\startitem
    So called \PDF\ literals can interfere badly with font switches at the \PDF\
    level and are therefore very inefficient.
\stopitem
\startitem
    In order to properly support effects at the font level, we need to be able to
    inject the right \PDF\ code in a more clever way.
\stopitem
\startitem
    Two new keys were added to the font file definition table: \type{width} and
    \type {mode}. When set these inject a \PDF\ line width operation and trigger the
    right rendering mode (backend).
\stopitem
\stopitemize

\stoptitle

\starttitle[title=What interface do we need]

\startbuffer
\definefontfeature[effect-1][effect={width=0.8}]
\definefontfeature[bbox]    [boundingbox=frame]

\definefont
  [EffectiveFont]
  [BenchMark*default,effect-1,bbox @ 12pt]
\stopbuffer

\typebuffer \getbuffer

\startlinecorrection[2*big]
\scale[width=\textwidth]{\backgroundline[maincolor]{\EffectiveFont effective}}
\stoplinecorrection

\page

\startbuffer
\definefontfeature[effect-2][effect={width=1.1,wdelta=1.20}]
\definefontfeature[effect-3][effect={width=1.1,wdelta=1.80}]

\definefont
  [EffectiveFontA]
  [BenchMark*default,effect-2 @ 12pt]

\definefont
  [EffectiveFontB]
  [BenchMark*default,effect-3 @ 12pt]
\stopbuffer

\typebuffer \getbuffer

\scale[width=\textwidth]{\darkgray\showglyphs \EffectiveFontA effect \EffectiveFontB effect}

\stoptitle

\starttitle[title=Can we do better]

\startitemize
\startitem
    This is still not good enough so next came playing with extended shapes. This is an
    old feature inherited from \POSTSCRIPT\ times and \PDFTEX.
\stopitem
\startitem
    The \LUATEX\ backend is very efficient with this kind of trickery and combines
    it with font scaling.
\stopitem
\startitem
    It was trivial to add a similar scaling in the vertical direction.
\stopitem
\stopitemize

\page

\startbuffer
\definefontfeature[effect-4]
  [effect={width=0.5,wdelta=1.5}]

\definefontfeature[effect-5]
  [effect={width=0.5,wdelta=1.5,extend=1.2}]

\definefont
  [EffectiveFontA]
  [BenchMark*default,effect-4 @ 12pt]

\definefont
  [EffectiveFontB]
  [BenchMark*default,effect-5 @ 12pt]
\stopbuffer

\typebuffer \getbuffer

\startlinecorrection[2*big]
\scale[width=\textwidth]{\darkgray\showglyphs \EffectiveFontA effect \EffectiveFontB effect}
\stoplinecorrection

\page

\startbuffer
\definefontfeature[effect-6]
  [effect={width=0.5,wdelta=1.50}]

\definefontfeature[effect-7]
  [effect={width=0.5,wdelta=1.50,squeeze=1.2}]

\definefont
  [EffectiveFontA]
  [BenchMark*default,effect-6 @ 12pt]

\definefont
  [EffectiveFontB]
  [BenchMark*default,effect-7 @ 12pt]
\stopbuffer

\typebuffer \getbuffer

\startlinecorrection[2*big]
\scale[width=\textwidth]{\darkgray\showglyphs \EffectiveFontA effect \EffectiveFontB effect}
\stoplinecorrection

\stoptitle

\starttitle[title=How about math]

\startitemize
\startitem
    I never really needed this kind of trickery but it might be handy for
    bold math in titles.
\stopitem
\startitem
    But math is kind of special as it has extensibles, uses rules and is controlled
    by math parameters.
\stopitem
\startitem
    Math parameters are global for a formula so that doesn't work out well for mixed
    families using fonts with different design parameters.
\stopitem
\stopitemize

\page

\starttyping
\switchtobodyfont[modern]

$\sqrt{\frac{\frac{1}{a}}{\frac{2}{b}}}$

\switchtobodyfont[modernlatin]

$\mr \sqrt{\frac{\frac{1}{a}}{\frac{2}{b}}}$
$\mb \sqrt{\frac{\frac{1}{a}}{\frac{2}{b}}}$
\stoptyping

\startlinecorrection
\startcombination[3*1]
    {\maincolor\switchtobodyfont     [modern]\scale[height=.25\textwidth]{$\sqrt{\frac{\frac{1}{a}}{\frac{2}{b}}}$}} {\tttf latinmodern}
    {\maincolor\switchtobodyfont[modernlatin]\scale[height=.25\textwidth]{$\sqrt{\frac{\frac{1}{a}}{\frac{2}{b}}}$}} {\tttf modernlatin}
    {\maincolor\switchtobodyfont[modernlatin]\scale[height=.25\textwidth]{$\sqrt{\frac{\frac{1}{a}}{\frac{2}{b}}}$}} {\tttf modernlatin}
\stopcombination
\stoplinecorrection

\stoptitle

\starttitle[title=Is it useful]

\startitemize
\startitem
    \start \definedfont[BenchMark*default]%
    For reading on a different medium than paper a bit bolder font often
    works better. This is a normal Latin Modern.\stop
\stopitem
\startitem
    Here we use the \type {modernlatin} For reading on a different medium than
    paper a bit bolder font often works better.
\stopitem
\startitem
    In my opinion a slightly bolder Latin Modern looks a bit more modern, but
    that's of course just an opinion.
\stopitem
\startitem
    I'm not sure if and when I will use this new trickery; maybe to compensate the
    lack of bold math fonts.
\stopitem
\startitem
    Performance wise there is no penalty. File don't get larger. Rendering seems to
    be somewhat slower.
\stopitem
\startitem
    In the end it's probably just another example of feature creep or \TEX\ hobbyism.
\stopitem
\stopitemize

\stoptitle

\starttitle[title=Kerning]

\startMPinclusions
    def SampleShapes(expr dx, offset, pw, k) =
        picture p ; p := image (
            draw               fullcircle scaled 1cm                   withcolor "maincolor" ;
            draw               fullsquare scaled 1cm  shifted (dx+k,0) withcolor "maincolor" ;
            draw point 8   of (fullcircle scaled 1cm)                  withcolor white ;
            draw point 3.5 of (fullsquare scaled 1cm) shifted (dx+k,0) withcolor white ;
        ) shifted (offset,0) ;
        draw p withpen pencircle scaled pw ;
        draw boundingbox p withcolor white ;
    enddef ;
\stopMPinclusions

\startitemize
\startitem
    To what extent do we need to compensate dimensions in order to get the kerning
    acceptable.
\stopitem
\startitem
    Messing around with font features is fragile because there is not much consistency in
    how these are organized.
\stopitem
\stopitemize

\startlinecorrection[2*big]
\startMPcode
    SampleShapes(15mm,  0mm,1mm,0mm) ;
    SampleShapes(15mm, 40mm,2mm,0mm) ;
    SampleShapes(17mm, 80mm,2mm,0mm) ;
\stopMPcode
\stoplinecorrection

\startlinecorrection[2*big]
\startMPcode
    SampleShapes(15mm,  0mm,1mm,0mm) ;
    SampleShapes(15mm, 40mm,2mm,2mm) ;
    SampleShapes(17mm, 80mm,2mm,2mm) ;
\stopMPcode
\stoplinecorrection

\startlinecorrection[2*big]
\startMPcode
    SampleShapes(10mm,  0mm,1mm,0mm) ;
    SampleShapes(10mm, 40mm,1mm,1mm) ;
    SampleShapes(10mm, 80mm,2mm,0mm) ;
    SampleShapes(10mm,120mm,2mm,2mm) ;
\stopMPcode
\stoplinecorrection

\stoptitle

\starttitle[title=Ligatures]

\definefontfeature
  [demo-1]
  [default]
  [hlig=yes]

\definefontfeature
  [demo-2]
  [demo-1]
  [effect=0.5]

\startitemize
\startitem
    Ligatures are even less predictable so this is why we cannot apply too much
    effect.
\stopitem
\startitem
    There can be artifacts due to the way characters are combined (like in Latin
    Modern).
\stopitem
\stopitemize

\startlinecorrection
\startcombination[1*3]
    { \scale [width=.8\textwidth] {
        \definedfont[texgyrepagellaregular*demo-1]fist effe
        \par
        \definedfont[texgyrepagellaregular*demo-2]fist effe
    } } {
        \tttf \maincolor texgyre pagella regular
    } { \scale [width=.8\textwidth] {
        \definedfont[cambria*demo-1]fist effe
        \par
        \definedfont[cambria*demo-2]fist effe
    } } {
        \tttf \maincolor cambria
    } { \scale [width=.8\textwidth] {
        \definedfont[ebgaramond12regular*demo-1]fist effe
        \par
        \definedfont[ebgaramond12regular*demo-2]fist effe
    } } {
        \tttf \maincolor ebgaramond 12 regular
    }
\stopcombination
\stoplinecorrection

\stoptitle

\starttitle[title=Finetuning]

\startbuffer
\definefontfeature[lm-bald]
  [effect={width=0.25,effect=both}]
\definefontfeature[pg-bald]
  [effect={width=0.25,effect=both}]
\definefontfeature[dj-bald]
  [effect={width=0.35,effect=both}]

\definefontfeature[lm-bold]
  [effect={width=0.25,hdelta=0,ddelta=0,effect=both,
    extend=1.10}]

\definefontfeature[pg-bold]
  [effect={width=0.25,hdelta=0,ddelta=0,effect=both,
    extend=1.00}]

\definefontfeature[dj-bold]
  [effect={width=0.35,hdelta=0,ddelta=0,effect=both,
    extend=1.05}]
\stopbuffer

\definefont[lmbald][Serif*default,lm-bald sa d]
\definefont[pgbald][Serif*default,pg-bald sa d]
\definefont[djbald][Serif*default,dj-bald sa d]

\definefont[lmbold][Serif*default,lm-bold sa d]
\definefont[pgbold][Serif*default,pg-bold sa d]
\definefont[djbold][Serif*default,dj-bold sa d]

\typebuffer \getbuffer

\page

\starttabulate[|l|l|l|l|]
\NC
    \NC
    \tt \maincolor modern  \NC
    \tt \maincolor pagella \NC
    \tt \maincolor dejavu  \NC
\NR
\NC
    \maincolor \type{\tfd} \NC
    \switchtobodyfont [modern,24pt]\strut\ruledhbox{\tfd    ABC}\NC
    \switchtobodyfont[pagella,24pt]\strut\ruledhbox{\tfd    ABC}\NC
    \switchtobodyfont [dejavu,24pt]\strut\ruledhbox{\tfd    ABC}\NC
\NR
\NC
    \maincolor \type{\..bald} \NC
    \switchtobodyfont [modern,24pt]\strut\ruledhbox{\lmbald ABC}\NC
    \switchtobodyfont[pagella,24pt]\strut\ruledhbox{\pgbald ABC}\NC
    \switchtobodyfont [dejavu,24pt]\strut\ruledhbox{\djbald ABC}\NC
\NR
\NC
    \maincolor \type{\bfd} \NC
    \switchtobodyfont [modern,24pt]\strut\ruledhbox{\bfd    ABC}\NC
    \switchtobodyfont[pagella,24pt]\strut\ruledhbox{\bfd    ABC}\NC
    \switchtobodyfont [dejavu,24pt]\strut\ruledhbox{\bfd    ABC}\NC
\NR
\NC
    \maincolor \type{\..bold} \NC
    \switchtobodyfont [modern,24pt]\strut\ruledhbox{\lmbold ABC}\NC
    \switchtobodyfont[pagella,24pt]\strut\ruledhbox{\pgbold ABC}\NC
    \switchtobodyfont [dejavu,24pt]\strut\ruledhbox{\djbold ABC}\NC
\NR
\stoptabulate

\stoptitle

\starttitle[title=Pagella]

\startbuffer
\definefontfeature
  [pg-fake-1]
  [effect={width=0.25,effect=both}]

\definefontfeature
  [pg-fake-2]
  [effect={width=0.25,hdelta=0,ddelta=0,effect=both}]

\definefont[pgregular]  [Serif*default]
\definefont[pgbold]     [SerifBold*default]
\definefont[pgfakebolda][Serif*default,pg-fake-1]
\definefont[pgfakeboldb][Serif*default,pg-fake-2]

\definecolor[color-pgregular]  [t=.5,a=1,r=.6]
\definecolor[color-pgbold]     [t=.5,a=1,g=.6]
\definecolor[color-pgfakebolda][t=.5,a=1,b=.6]
\definecolor[color-pgfakeboldb][t=.5,a=1,r=.6,g=.6]
\stopbuffer

\typebuffer

\page

\startbuffer[sample]

\start \switchtobodyfont[pagella]  \getbuffer

\startcombination[2*2]
    {
        \scale [width=\measure{combination}] {
            \ruledhbox{\showglyphs\pgregular   \SampleWord}
        }
    } {
        regular
    } {
        \scale [width=\measure{combination}] {
            \ruledhbox{\showglyphs\pgbold      \SampleWord}
        }
    } {
        bold
    } {
        \scale [width=\measure{combination}] {
            \ruledhbox{\showglyphs\pgfakebolda \SampleWord}
        }
    } {
        fakebolda
    } {
        \scale [width=\measure{combination}] {
            \ruledhbox{\showglyphs\pgfakeboldb \SampleWord}
        }
    } {
        fakeboldb
    }
\stopcombination

\stop

\page

\start \switchtobodyfont[pagella]  \getbuffer

\startcombination[2*3]
    {
        \scale [width=.35\textwidth] {
            \startoverlay
                {\color[color-pgregular]  {\pgregular   \SampleWord}}
                {\color[color-pgbold]     {\pgbold      \SampleWord}}
            \stopoverlay
        }
    } {
        bold over regular
    } {
        \scale [width=.35\textwidth] {
            \startoverlay
                {\color[color-pgregular]  {\pgregular   \SampleWord}}
                {\color[color-pgfakeboldb]{\pgfakeboldb \SampleWord}}
            \stopoverlay
        }
    } {
        fakebolda over regular
    } {
        \scale [width=.35\textwidth] {
            \startoverlay
                {\color[color-pgregular]  {\pgregular   \SampleWord}}
                {\color[color-pgfakebolda]{\pgfakeboldb \SampleWord}}
            \stopoverlay
        }
    } {
        fakeboldb over regular
    } {
        \scale [width=.35\textwidth] {
            \startoverlay
                {\color[color-pgbold]     {\pgbold      \SampleWord}}
                {\color[color-pgfakeboldb]{\pgfakeboldb \SampleWord}}
            \stopoverlay
        }
    } {
        fakeboldb over bold
    } {
        \scale [width=.35\textwidth] {
            \startoverlay
                {\color[color-pgfakebolda]{\pgfakebolda \SampleWord}}
                {\color[color-pgfakeboldb]{\pgfakeboldb \SampleWord}}
            \stopoverlay
        }
    } {
         fakeboldb over fakebolda
    } {
        \scale [width=.35\textwidth] {
            \startoverlay
                {\color[color-pgregular]  {\pgregular   \SampleWord}}
                {\color[color-pgbold]     {\pgbold      \SampleWord}}
                {\color[color-pgfakebolda]{\pgfakebolda \SampleWord}}
                {\color[color-pgfakeboldb]{\pgfakeboldb \SampleWord}}
            \stopoverlay
        }
    } {
         all four overlayed
    }
\stopcombination

\stop

\stopbuffer

\def\SampleWord{\^o\"ep\c s}    \getbuffer[sample]
\def\SampleWord{London Grammar} \getbuffer[sample]

\stoptitle

\starttitle[title=Arabic]

\startbuffer
\definefontfeature
  [bolden-arabic-1]
  [effect={width=0.4}]

\definefontfeature
  [bolden-arabic-2]
  [effect={width=0.4,effect=outer}]

\definefontfeature
  [bolden-arabic-3]
  [effect={width=0.5,wdelta=0.5,ddelta=.2,hdelta=.2,factor=.1}]
\stopbuffer

\typebuffer \getbuffer

\startbuffer

\setupalign
  [righttoleft]

\setupinterlinespace
  [1.5]

\start
  \definedfont[arabictest*arabic,bolden-arabic-1 @ 30pt]
  \samplefile{khatt-ar}\blank
  \definedfont[arabictest*arabic,bolden-arabic-2 @ 30pt]
  \samplefile{khatt-ar}\blank
  \definedfont[arabictest*arabic,bolden-arabic-3 @ 30pt]
  \samplefile{khatt-ar}\blank
\stop
\stopbuffer

\page \start \definefontsynonym[arabictest][arabtype] \getbuffer\stop

\page \start \definefontsynonym[arabictest][husayni]  \getbuffer\stop

\stoptitle

\starttitle[title=Marks and cursive]

\startitemize
\startitem
    Marks are tricky because they can be anchored at any location and we can
    only guess what should be done.
\stopitem
\startitem
    Cursive connections still need to connect and we don't know in advance
    how shapes overlap.
\stopitem
\stopitemize

\startMPinclusions
    def DrawShapes(expr how) =
        def SampleShapes(expr offset, pw, xc, xs, xt, yc, ys, yt, txt, more) =
            numeric l ; l := pw * mm ;
            picture p ; p := image (
                draw fullcircle   scaled 10 ;
                draw fullcircle   scaled  3 shifted (-3+xc  ,8+yc) withcolor "darkred" ;
                draw fullsquare   scaled  3 shifted ( 6+xs  ,7+ys) withcolor "darkblue";
                draw fulltriangle scaled  4 shifted ( 6+xt+5,6+yt) withcolor "darkgreen";
            ) shifted (offset,0) scaled mm ;
            draw p
                withpen pencircle
                    if how = 2 :
                        xscaled l yscaled (l/2) rotated 30 ;
                    else :
                        scaled l ;
                    fi ;
            draw boundingbox p
                withcolor "darkyellow" ;
            draw textext(txt)
                shifted (xpart center p, -8mm) ;
            draw textext(more)
                shifted (xpart center p, -11mm) ;
        enddef ;
        SampleShapes(  0,1, 0,0,0, 0,   0,   0,  "\tinyfont \setstrut \strut original",   "\tinyfont \setstrut \strut ") ;
        SampleShapes( 25,2, 0,0,0, 0,   0,   0,  "\tinyfont \setstrut \strut instance",   "\tinyfont \setstrut \strut ") ;
        SampleShapes( 50,2,-1,1,0, 0,   0,   0,  "\tinyfont \setstrut \strut mark",       "\tinyfont \setstrut \strut x only") ;
        SampleShapes( 75,2,-1,1,1, 0,   0,   0,  "\tinyfont \setstrut \strut mark + mkmk","\tinyfont \setstrut \strut x only") ;
        SampleShapes(100,2,-1,1,1, 1,   1,   1,  "\tinyfont \setstrut \strut mark + mkmk","\tinyfont \setstrut \strut x and y") ;
        SampleShapes(125,2,-1,2,2,-1/2,-1/2,-1/2,"\tinyfont \setstrut \strut mark + mkmk","\tinyfont \setstrut \strut x and -y") ;
    enddef ;
\stopMPinclusions

\startlinecorrection[2*big]
\scale
  [width=\textwidth]
  {\startMPcode DrawShapes(1) ; \stopMPcode}
\stoplinecorrection

\startlinecorrection[2*big]
\scale
  [width=\textwidth]
  {\startMPcode DrawShapes(2) ; \stopMPcode}
\stoplinecorrection

\stoptitle

\starttitle[title=Radicals and such]

Radicals are constructed using rules and extensible characters. Especially the rules
need to be adapted.

\startbuffer[mathblob]
\def\MathSample
  {2\times\sqrt{\frac{\sqrt{\frac{\sqrt{2}}{\sqrt{2}}}}
     {\sqrt{\frac{\sqrt{2}}{\sqrt{2}}}}}}
\stopbuffer

\startbuffer
$\mr \darkblue  \MathSample \quad
 \mb \darkgreen \MathSample $
\stopbuffer

\getbuffer[mathblob]

\typebuffer

\startlinecorrection[blank]
\scale[width=\textwidth]{\switchtobodyfont[modernlatin,24pt]\getbuffer}
\stoplinecorrection

\page

\startbuffer
\dostepwiserecurse {1} {30} {5} {
  $
    \mr \sqrt{\blackrule[width=2mm,height=#1mm,color=darkblue]}
    \quad
    \mb \sqrt{\blackrule[width=2mm,height=#1mm,color=darkgreen]}
  $
}
\stopbuffer

\typebuffer

\startlinecorrection[blank]
\scale[width=\textwidth]{\switchtobodyfont[modernlatin,24pt]\getbuffer}
\stoplinecorrection

\page

\definecolor[colormr] [t=.5,a=1,b=.6]
\definecolor[colormb] [t=.5,a=1,g=.6]

% and a fix in \LUATEX: pickup the value from the font instead of the currently

\startlinecorrection
\midaligned{\scale[height=.6\textheight]{\startoverlay
    {\color[colormb]{$\mb\sqrt{\frac{1}{x}}$}}
    {\color[colormr]{$   \sqrt{\frac{1}{x}}$}}
\stopoverlay}}
\stoplinecorrection

\page

\unexpanded\def\ShowMathSample#1%
  {\switchtobodyfont[#1,14.4pt]%
   \mathematics{%
    \mr \darkblue  \MathSample \quad
    \mb \darkgreen \MathSample
   }}

\unexpanded\def\ShowMathCaption#1%
  {\switchtobodyfont[#1]%
   #1:
   $
   {\mr2\enspace \scriptstyle2\enspace \scriptscriptstyle2}
   \enspace
   {\mb2\enspace \scriptstyle2\enspace \scriptscriptstyle2}
   $}

\midaligned{\startcombination[3*2]
    {\ShowMathSample {dejavu}} {\ShowMathCaption{dejavu}}
    {\ShowMathSample{pagella}} {\ShowMathCaption{pagella}}
    {\ShowMathSample {termes}} {\ShowMathCaption{termes}}
    {\ShowMathSample  {bonum}} {\ShowMathCaption{bonum}}
    {\ShowMathSample {schola}} {\ShowMathCaption{schola}}
    {\ShowMathSample{cambria}} {\ShowMathCaption{cambria}}
\stopcombination}

\page

\starttyping
\definefontfeature
  [boldened-30]
  [effect={width=0.3,extend=1.15,squeeze=0.985,%
    delta=1,hdelta=0.225,ddelta=0.225,vshift=0.225}]

\definefontfeature
  [boldened-30]
  [effect={width=0.30,auto=yes}]
\stoptyping

\stoptitle

\starttitle[title=An application]

\def\MathSample
  {\overbrace{2 +
     \sqrt{\frac{\sqrt{\frac{\sqrt{2}}{\sqrt{2}}}}
       {\sqrt{\frac{\sqrt{\underbar{2}}}{\sqrt{\overbar{2}}}}}}}}

\startbuffer
\definehead [mysectiona] [section]
\definehead [mysectionb] [mysectiona]

\setuphead
  [mysectiona]
  [style=\tfc,
   color=darkblue,
   before=\blank,
   after=\blank]

\setuphead
  [mysectionb]
  [style=\bfc,
   color=darkred]

\mysectiona{Regular\quad$\MathSample\quad\mb\MathSample$}
\mysectionb{Bold   \quad$\MathSample\quad\mb\MathSample$}
\stopbuffer

\typebuffer \page \getbuffer \page

\startcolumns
    \switchtobodyfont[modern,12pt]      \setupinterlinespace[15pt] \samplefile{poe} \column
    \switchtobodyfont[modernlatin,12pt] \setupinterlinespace[15pt] \samplefile{poe} % \column
\stopcolumns

\stoptitle

\stoptext