luametafun-followtext.tex /size: 3386 b    last modification: 2021-10-28 13:50
1% language=us runpath=texruns:manuals/luametafun
2
3\environment luametafun-style
4
5\startcomponent luametafun-followtext
6
7\startchapter[title={Followtext}]
8
9Typesetting text along a path started as a demo if communication between \TEX\ and
10\METAPOST\ in the early days of \METAFUN. In the meantime the implementation has
11been modernized a few times and the current implementation feels okay, especially
12now that we have a better user interface. Here is an example:
13
14\startbuffer[1a]
15\startMPcode{doublefun}
16    draw lmt_followtext [
17        text   = "How well does it work {\bf 1}! ",
18        path   = fullcircle scaled 4cm,
19        trace  = true,
20        spread = true,
21    ] ysized 5cm ;
22\stopMPcode
23\stopbuffer
24
25\typebuffer[1a][option=TEX]
26
27Here is the same example but with the text in the reverse order. The results of both examples
28are shown in \in {figure} [followtext:1].
29
30\startbuffer[1b]
31\startMPcode{doublefun}
32    draw lmt_followtext [
33        text    = "How well does it work {\bf 2}! ",
34        path    = fullcircle scaled 4cm,
35        trace   = true,
36        spread  = false,
37        reverse = true,
38    ] ysized 5cm ;
39\stopMPcode
40\stopbuffer
41
42\typebuffer[1b][option=TEX]
43
44\startplacefigure[reference=followtext:1]
45    \startcombination[2*2]
46       {\getbuffer[1a]} {}
47       {\getbuffer[1b]} {}
48    \stopcombination
49\stopplacefigure
50
51There are not that many options. One is \type {autoscale} which makes the shape
52and text match. \in {Figure} [followtext:2] shows what happens.
53
54\startbuffer[2a]
55\startMPcode{doublefun}
56    draw lmt_followtext [
57        text        = "How well does it work {\bf 3}! ",
58        trace       = true,
59        autoscaleup = "yes"
60    ] ysized 5cm ;
61\stopMPcode
62\stopbuffer
63
64\typebuffer[2a][option=TEX]
65
66\startbuffer[2b]
67\startMPcode{doublefun}
68    draw lmt_followtext [
69        text        = "How well does it work {\bf 4}! ",
70        path        = fullcircle scaled 2cm,
71        trace       = true,
72        autoscaleup = "max"
73    ] ysized 5cm ;
74\stopMPcode
75\stopbuffer
76
77\typebuffer[2b][option=TEX]
78
79\startplacefigure[reference=followtext:2]
80    \startcombination[2*2]
81       {\getbuffer[2a]} {}
82       {\getbuffer[2b]} {}
83    \stopcombination
84\stopplacefigure
85
86You can use quite strange paths, like the one show in \in {figure}
87[followtext:3]. Watch the parenthesis around the path. this is really needed in
88order for the scanner to pick up the path (otherwise it sees a pair).
89
90\startbuffer[3]
91\startMPcode{doublefun}
92    draw lmt_followtext [
93        text        = "\samplefile {zapf}",
94        path        = ((3,0) .. (1,0) .. (5,0) .. (2,0) .. (4,0) .. (3,0)),
95        autoscaleup = "max"
96    ] xsized TextWidth ;
97\stopMPcode
98\stopbuffer
99
100\typebuffer[3][option=TEX]
101
102\startplacefigure[reference=followtext:3]
103    \getbuffer[3]
104\stopplacefigure
105
106The small set of options is:
107
108\starttabulate[|T|T|T|p|]
109\FL
110\BC name          \BC type    \BC default      \BC comment \NC \NR
111\ML
112\NC text          \NC string  \NC              \NC \NC \NR
113\NC spread        \NC string  \NC true         \NC \NC \NR
114\NC trace         \NC numeric \NC false        \NC \NC \NR
115\NC reverse       \NC numeric \NC false        \NC \NC \NR
116\NC autoscaleup   \NC numeric \NC no           \NC \NC \NR
117\NC autoscaledown \NC string  \NC no           \NC \NC \NR
118\NC path          \NC string  \NC (fullcircle) \NC \NC \NR
119\LL
120\stoptabulate
121
122\stopchapter
123
124\stopcomponent
125