1
2
3\environment luametafunstyle
4
5\startcomponent luametafunoutline
6
7\startchapter[title={Outline}]
8
9In a regular text you can have outline characters by setting a (pseudo) font
10feature but sometimes you want to play a bit more with this. In \METAFUN\ we
11always had that option. In \MKII\ we call \type {pstoedit} to turn text into
12outlines, in \MKIV\ we do that by manipulating the shapes directly. And, as with
13some other extensions, in \LMTX\ a new interface has been added, but the
14underlying code is the same as in \MKIV.
15
16\startbuffer[1a]
17\startMPcode{doublefun}
18 draw lmt_outline [
19 text = "hello"
20 kind = "draw",
21 drawcolor = "darkblue",
22 ] xsized .45TextWidth ;
23\stopMPcode
24\stopbuffer
25
26\startbuffer[1b]
27\startMPcode{doublefun}
28 draw lmt_outline [
29 text = "hello",
30 kind = "both",
31 fillcolor = "middlegray",
32 drawcolor = "darkgreen",
33 rulethickness = 15,
34 ] xsized .45TextWidth ;
35\stopMPcode
36\stopbuffer
37
38In \in {figure} [outline:1] we see two examples:
39
40\typebuffer[1a][option=TEX]
41
42and
43
44\typebuffer[1b][option=TEX]
45
46\startplacefigure[reference=outline:1,title={Drawing andor filling an outline.}]
47 \startcombination
48 {\getbuffer[1a]} {\type {kind=draw}}
49 {\getbuffer[1b]} {\type {kind=both}}
50 \stopcombination
51\stopplacefigure
52
53Normally the fill ends up below the draw but we can reverse the order, as in
54\in {figure} [outline:2], where we coded the leftmost example as:
55
56\startbuffer[2a]
57\startMPcode{doublefun}
58 draw lmt_outline [
59 text = "hello",
60 kind = "reverse",
61 fillcolor = "darkred",
62 drawcolor = "darkblue",
63 rulethickness = 12,
64 ] xsized .45TextWidth ;
65\stopMPcode
66\stopbuffer
67
68\startbuffer[2b]
69\startMPcode{doublefun}
70 draw lmt_outline [
71 text = "hello",
72 kind = "both",
73 fillcolor = "darkred",
74 drawcolor = "darkblue",
75 rulethickness = 12,
76 ] xsized .45TextWidth ;
77\stopMPcode
78\stopbuffer
79
80\typebuffer[2a][option=TEX]
81
82\startplacefigure[reference=outline:2,title={Reversing the order of drawing and filling.}]
83 \startcombination
84 {\getbuffer[2a]} {\type {kind=reverse}}
85 {\getbuffer[2b]} {\type {kind=both}}
86 \stopcombination
87\stopplacefigure
88
89It is possible to fill and draw in one operation, in which case the same color is
90used for both, see \in {figure} [outline:3] for an example fo this. This is a low
91level optimization where the shape is only output once.
92
93\startbuffer[3a]
94\startMPcode{doublefun}
95 draw lmt_outline [
96 text = "hello",
97 kind = "fillup",
98 fillcolor = "darkgreen",
99 rulethickness = 15,
100 ] xsized .45TextWidth ;
101\stopMPcode
102\stopbuffer
103
104\startbuffer[3b]
105\startMPcode{doublefun}
106 draw lmt_outline [
107 text = "hello",
108 kind = "fill",
109 fillcolor = "darkgreen",
110 rulethickness = 15,
111 ] xsized .45TextWidth ;
112\stopMPcode
113\stopbuffer
114
115\startplacefigure[reference=outline:3,title={Combining a fill with a draw in the same color.}]
116 \startcombination
117 {\getbuffer[3a]} {\type {kind=fillup}}
118 {\getbuffer[3b]} {\type {kind=fill}}
119 \stopcombination
120\stopplacefigure
121
122
123This interface is much nicer than the one where each variant (the parameter \type
124{kind} above) had its own macro due to the need to group properties of the
125outline and fill. Lets show some more:
126
127\startbuffer[4]
128\startMPcode{doublefun}
129 draw lmt_outline [
130 text = "\obeydiscretionaries\samplefile{tufte}",
131 align = "normal",
132 kind = "draw",
133 drawcolor = "darkblue",
134 ] xsized TextWidth ;
135\stopMPcode
136\stopbuffer
137
138\typebuffer[4][option=TEX]
139
140In this case we feed the text into the \type {\framed} macro so that we get a
141properly aligned paragraph of text, as demonstrated in \in {figure} [outline:4]
142\in {and} [outline:5]. If you want more trickery you can of course use any
143\CONTEXT\ command (including \type {\framed} with all kind of options) in the
144text.
145
146\startplacefigure[reference=outline:4,title={Outlining a paragraph of text.}]
147 \getbuffer[4]
148\stopplacefigure
149
150\startbuffer[5]
151\startMPcode{doublefun}
152 draw lmt_outline [
153 text = "\obeydiscretionaries\samplefile{ward}",
154 align = "normal,tolerant",
155 style = "bold",
156 width = 10cm,
157 kind = "draw",
158 drawcolor = "darkblue",
159 ] xsized TextWidth ;
160\stopMPcode
161\stopbuffer
162
163\typebuffer[5][option=TEX]
164
165\startplacefigure[reference=outline:4,title={Outlining a paragraph of text with a specific width.}]
166 \getbuffer[5]
167\stopplacefigure
168
169We summarize the parameters:
170
171\starttabulate[TTTp]
172\FL
173\BC name \BC type \BC default \BC comment \NC \NR
174\ML
175\NC text \NC string \NC \NC \NC \NR
176\NC kind \NC string \NC draw \NC One of \type {draw}, \type {fill}, \type {both}, \type {reverse} and \type {fillup}. \NC \NR
177\NC fillcolor \NC string \NC \NC \NC \NR
178\NC drawcolor \NC string \NC \NC \NC \NR
179\NC rulethickness \NC numeric \NC 110 \NC \NC \NR
180\NC align \NC string \NC \NC \NC \NR
181\NC style \NC string \NC \NC \NC \NR
182\NC width \NC numeric \NC \NC \NC \NR
183\LL
184\stoptabulate
185
186\stopchapter
187
188\stopcomponent
189 |