1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17\unprotect
18
19
20
21
22
23
24\ifdefined\startshapetext \else
25 \writestatus{system}{something is wrong here}
26\fi
27
28
29
30
31
32
33
34
35
36
37
38\definefontfeature[mp:tp][liga=no]
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54\protected\def\dofollowtokens#1#2
55 {\dontleavehmode
56 \vpack\bgroup
57 \forgetall
58 \dontcomplain
59 \addff{mp:tp}
60 \startMPcode
61 \includeMPgraphic{followtokens}
62 draw lmt_followtext [ path = RotPath, text = "#2", spread = #1 ] ;
63 \stopMPcode
64 \egroup}
65
66\protected\def\followtokens {\dofollowtokens{true}}
67\protected\def\followtokenscentered{\dofollowtokens{false}}
68
69
70
71\startuseMPgraphic{fuzzycount}
72 begingroup
73 save height, span, drift, d, cp ;
74 height := 3 5 LineHeight ;
75 span := 1 3 height ;
76 drift := 110 height ;
77 pickup pencircle scaled (112 height) ;
78 def d = (uniformdeviate drift) enddef ;
79 for i := 1 upto \MPvar{n} :
80 draw
81 if (i mod 5)=0 : ((d 4.5span,d) -- (d -0.5span,height d))
82 else : ((d, d) -- (d, height d)) fi
83 shifted (spani,ddrift) ;
84 endfor;
85 picture cp ; cp := currentpicture ;
86 setbounds currentpicture to
87 (llcorner cp shifted (0,ypart llcorner cp) --
88 lrcorner cp shifted (0,ypart lrcorner cp) --
89 urcorner cp --
90 ulcorner cp -- cycle) ;
91 endgroup ;
92\stopuseMPgraphic
93
94\setupMPvariables
95 [fuzzycount]
96 [n=10]
97
98\protected\def\fuzzycount#1
99 {\dontleavehmode\bgroup
100 \tx
101 \useMPgraphic{fuzzycount}{n=#1}
102 \egroup}
103
104\defineconversion[fuzzy][\fuzzycount]
105
106
107
108\setupMPvariables
109 [EnglishRule]
110 [height=1ex,
111 width=\localhsize,
112 color=darkgray]
113
114\defineblank
115 [EnglishRule]
116 [medium]
117
118\startuniqueMPgraphic{EnglishRule}{height,width,color}
119 x1 = 0 ; x3 = \MPvar{width} ; x2 = x4 = .5x3 ;
120 y1 = y3 = 0 ; y2 = y4 = \MPvar{height} 2 ;
121 fill z1 .. z2 .. z3 & z3 .. z4 .. z1 & cycle withcolor \MPvar{color} ;
122\stopuniqueMPgraphic
123
124\protected\def\EnglishRule
125 {\startlinecorrection[EnglishRule]
126 \setlocalhsize
127 \noindentation
128 \reuseMPgraphic{EnglishRule}
129 \stoplinecorrection}
130
131
132
133
134
135
136
137
138
139
140\protected\def\TightText#1#2#3#4
141 {\hpack
142 {\startMPcode
143 picture p ; p := image (graphictext "#1" withfillcolor red) ;
144 draw p xsized #2 ysized #3 withcolor \MPcolor{#4} ;
145 \stopMPcode}}
146
147\protected\def\TightText#1#2#3#4
148 {\dontleavehmode
149 \startMPcode
150 draw outlinetext.f ("#1") (\iftok{#4}\emptytoks \else withcolor \MPcolor{#4} \fi)
151 \iftok{#2}\emptytoks \else xsized #2 \fi
152 \iftok{#3}\emptytoks \else ysized #3 \fi
153 ;
154 \stopMPcode}
155
156\protect
157
158\continueifinputfile{metaimptxt.mkxl}
159
160\setupbodyfont[pagella,10pt]
161
162
163
164\starttext
165
166
167
168\startuseMPgraphic{test 1}
169 path p ; p := fullcircle scaled 6cm ;
170
171 build_parshape(p,BodyFontSize2,0,0,LineHeight,StrutHeight,StrutDepth,StrutHeight) ;
172
173 draw p withpen pencircle scaled 1pt ;
174\stopuseMPgraphic
175
176\startuseMPgraphic{test 2}
177 path p ; p := fullsquare rotated 45 scaled 5cm ;
178
179 build_parshape(p,BodyFontSize2,0,0,LineHeight,StrutHeight,StrutDepth,StrutHeight) ;
180
181 draw p withpen pencircle scaled 1pt ;
182\stopuseMPgraphic
183
184\startuseMPgraphic{test 3}
185 numeric w, h ; w := h := 6cm ;
186 path p ; p := (.5w,h) -- (0,h) -- (0,0) -- (w,0) &
187 (w,0) .. (.75w,.5h) .. (w,h) & (w,h) -- cycle ;
188
189 build_parshape(p,BodyFontSize2,0,0,LineHeight,StrutHeight,StrutDepth,StrutHeight) ;
190
191 draw p withpen pencircle scaled 1pt ;
192\stopuseMPgraphic
193
194\startuseMPgraphic{test 4}
195 numeric w, h, o, d ;
196
197 def shape = (o,o) -- (wo,o) & (wo,o) .. (.75wo,.5h) ..
198 (w-2o,ho) & (w-2o,ho) -- (o,ho) -- cycle
199 enddef ;
200
201 d := BodyFontSize2;
202
203 w := h := 6cm ; o := d ; path p ; p := shape ;
204 w := h := 6cm ; o := 0 ; path q ; q := shape ;
205
206 build_parshape(p,q,d,d,LineHeight,StrutHeight,StrutDepth,StrutHeight) ;
207
208 draw q withpen pencircle scaled 1pt ;
209\stopuseMPgraphic
210
211\defineoverlay[test 1][\useMPgraphic{test 1}]
212\defineoverlay[test 2][\useMPgraphic{test 2}]
213\defineoverlay[test 3][\useMPgraphic{test 3}]
214\defineoverlay[test 4][\useMPgraphic{test 4}]
215
216\startbuffer
217\startshapetext[test 1,test 2,test 3,test 4]
218 \setupalign[verytolerant,stretch,normal]
219 \samplefile{douglas}
220\stopshapetext
221\startTEXpage[offset=10pt]
222 \startcombination[2*2]
223 {\framed[offset=overlay,frame=off,background=test 1]{\getshapetext}} {test 1}
224 {\framed[offset=overlay,frame=off,background=test 2]{\getshapetext}} {test 2}
225 {\framed[offset=overlay,frame=off,background=test 3]{\getshapetext}} {test 3}
226 {\framed[offset=overlay,frame=off,background=test 4]{\getshapetext}} {test 4}
227 \stopcombination
228\stopTEXpage
229\stopbuffer
230
231\getbuffer
232
233\startMPextensions
234 boolean trace_parshape ; trace_parshape := true ;
235\stopMPextensions
236
237\getbuffer
238
239
240
241\startitemize[fuzzy,nostopper]
242 \startitem This is real fuzzy. \stopitem
243 \startitem But it can be even more fuzzier. \stopitem
244 \startitem And how about this. \stopitem
245\stopitemize
246
247\EnglishRule
248
249\startitemize[continue,broad]
250 \startitem This is real fuzzy. \stopitem
251 \startitem But it can be even more fuzzier. \stopitem
252 \startitem And how about this. \stopitem
253\stopitemize
254
255
256
257\ruledhbox{\TightText{oeps wat doet dit}{10cm}{1cm}{red}} \blank
258\ruledhbox{\TightText{oeps wat doet dit}{10cm}{} {green}} \blank
259\ruledhbox{\TightText{oeps wat doet dit}{} {1cm}{blue}} \blank
260\ruledhbox{\TightText{oeps wat doet dit}{} {} {}} \blank
261
262
263
264\startuseMPgraphic{followtokens}
265 path RotPath ; RotPath := reverse halfcircle xyscaled 3cm ;
266 draw RotPath ;
267\stopuseMPgraphic
268
269\startTEXpage
270 \followtokens{{\hskip1em}some text{\hskip1em}}
271\stopTEXpage
272
273\startTEXpage
274 \followtokenscentered{{\hskip1em}some text{\hskip1em}}
275\stopTEXpage
276
277\stoptext
278 |