1
2
3
4
5
6
7
8
9
10
11
12
13
14\writestatus{loading}{ConTeXt Typesetting Macros Scripts}
15
16\unprotect
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39\installcorenamespace {low}
40\installcorenamespace {high}
41
42\installcommandhandler \??low {low} \??low
43\installcommandhandler \??high {high} \??high
44
45\setuplow [\c!style=\tx,\c!distance=\zeropoint,\c!down=.48\exheight]
46\setuphigh[\c!style=\tx,\c!distance=\zeropoint,\c!up =.86\exheight]
47
48\appendtoks \frozen\protected\edefcsname\currentlow \endcsname{\typo_scripts_low [\currentlow ]}\to \everydefinelow
49\appendtoks \frozen\protected\edefcsname\currenthigh\endcsname{\typo_scripts_high[\currenthigh]}\to \everydefinehigh
50
51\def\typo_scripts_distance#1
52 {\edef\p_distance{#1\c!distance}
53 \ifx\p_distance\v!tight
54 \tightfitboundary
55 \else
56 \kern\p_distance\relax
57 \fi}
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76\protected\def\typo_scripts_low[#1]#2
77 {\dontleavehmode
78 \begingroup
79 \cdef\currentlow{#1}
80 \typo_scripts_distance\lowparameter
81 \setbox\scratchbox\runninghbox\bgroup
82 \lower\lowparameter\c!down\hbox\bgroup
83 \ifempty\fontsize
84 \ifmmode
85 \mr
86 \else
87 \uselowstyleandcolor\c!style\c!color
88 \fi
89 \else
90 \uselowstyleandcolor\c!style\c!color
91 \fi
92 \dostarttagged\t!sub\currentlow
93 #2
94 \dostoptagged
95 \egroup
96 \egroup
97 \ht\scratchbox\strutht
98 \dp\scratchbox\strutdp
99 \box\scratchbox
100 \endgroup}
101
102\protected\def\typo_scripts_high[#1]#2
103 {\dontleavehmode
104 \begingroup
105 \cdef\currenthigh{#1}
106 \typo_scripts_distance\highparameter
107 \setbox\scratchbox\runninghbox\bgroup
108 \raise\highparameter\c!up\hbox\bgroup
109 \ifempty\fontsize
110 \ifmmode
111 \mr
112 \else
113 \usehighstyleandcolor\c!style\c!color
114 \fi
115 \else
116 \usehighstyleandcolor\c!style\c!color
117 \fi
118 \dostarttagged\t!sup\currenthigh
119 #2
120 \dostoptagged
121 \egroup
122 \egroup
123 \ht\scratchbox\strutht
124 \dp\scratchbox\strutdp
125 \box\scratchbox
126 \endgroup}
127
128\permanent\protected\def\low {\typo_scripts_low []}
129\permanent\protected\def\high{\typo_scripts_high[]}
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148\installcorenamespace {lowhigh}
149
150\installcommandhandler \??lowhigh {lowhigh} \??lowhigh
151
152\setuplowhigh
153 [\c!style=\tx,
154 \c!distance=.1\exheight,
155 \c!up=.96\exheight,
156 \c!down=.58\exheight]
157
158\appendtoks
159 \frozen\edefcsname\currentlowhigh\endcsname{\typo_scripts_lowhigh[\currentlowhigh]}
160\to \everydefinelowhigh
161
162\tolerant\protected\def\typo_scripts_lowhigh[#1]#*[#2]#:#3#4
163 {\dontleavehmode
164 \runninghbox\bgroup
165 \cdef\currentlowhigh{#1}
166 \typo_scripts_distance\lowhighparameter
167 \dostarttagged\t!subsup\currentlowhigh
168 \setbox\plusfour\hpack{\typo_scripts_lowhigh_low_high\lower\c!down\t!sub{#3}}
169 \setbox\plussix \hpack{\typo_scripts_lowhigh_low_high\raise\c!up \t!sup{#4}}
170 \edef\p_align{#2}
171 \ifx\p_align\v!left
172 \ifdim\wd\plusfour<\wd\plussix
173 \setbox\plusfour\hpack to \wd\plussix {\hss\box\plusfour}
174 \else
175 \setbox\plussix \hpack to \wd\plusfour{\hss\box\plussix }
176 \fi
177 \fi
178 \ifdim\wd\plusfour<\wd\plussix
179 \wd\plusfour\zeropoint
180 \box\plusfour
181 \box\plussix
182 \else
183 \wd\plussix\zeropoint
184 \box\plussix
185 \box\plusfour
186 \fi
187 \dostoptagged
188 \egroup}
189
190\def\typo_scripts_lowhigh_low_high#1#2#3#4
191 {\setbox\scratchbox\hpack\bgroup
192 #1\lowhighparameter#2\hbox\bgroup
193 \ifempty\fontsize
194 \ifmmode
195 \mr
196 \else
197 \uselowhighstyleandcolor\c!style\c!color
198 \fi
199 \else
200 \uselowhighstyleandcolor\c!style\c!color
201 \fi
202 \dostarttagged#3\empty
203 #4
204 \dostoptagged
205 \egroup
206 \egroup
207 \ht\scratchbox\strutht
208 \dp\scratchbox\strutdp
209 \box\scratchbox}
210
211\permanent\tolerant\protected\def\typo_scripts_highlow[#1]#*[#2]#:#3#4
212 {\typo_scripts_lowhigh[#1][#2]{#4}{#3}}
213
214\permanent\protected\def\lohi{\typo_scripts_lowhigh[]}
215\permanent\protected\def\hilo{\typo_scripts_highlow[]}
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238\installcorenamespace {lowmidhigh}
239
240\installcommandhandler \??lowmidhigh {lowmidhigh} \??lowmidhigh
241
242\setuplowmidhigh
243 [\c!style=\tx,
244 \c!up=.8\struthtdp,
245 \c!down=.8\struthtdp]
246
247\appendtoks
248 \frozen\edefcsname\currentlowmidhigh\endcsname{\typo_scripts_lowmidhigh[\currentlowmidhigh]}
249\to \everydefinelowmidhigh
250
251\protected\def\typo_scripts_lowmidhigh[#1]#2#3#4
252 {\dontleavehmode
253 \runninghbox\bgroup
254 \cdef\currentlowmidhigh{#1}
255 \dostarttagged\t!subsup\currentlowmidhigh
256 \uselowmidhighstyleandcolor\c!style\c!color
257 \setstrut
258 \setbox\plustwo \hbox{\strut\dostarttagged\t!sub\empty#2\dostoptagged}
259 \setbox\plusfour\hbox{\strut\dostarttagged\t!mid\empty#3\dostoptagged}
260 \setbox\plussix \hbox{\strut\dostarttagged\t!sup\empty#4\dostoptagged}
261 \scratchdimen \wd
262 \ifdim\wd\plustwo>\wd\plusfour
263 \ifdim\wd\plustwo>\wd\plussix
264 \plustwo
265 \else
266 \plussix
267 \fi
268 \else
269 \ifdim\wd\plusfour>\wd\plussix
270 \plusfour
271 \else
272 \plussix
273 \fi
274 \fi
275 \relax
276 \setbox\plustwo \hpack to \scratchdimen{\hss\lower\lowmidhighparameter\c!down\box\plustwo \hss}
277 \setbox\plusfour\hpack to \scratchdimen{\hss \box\plusfour\hss}
278 \setbox\plussix \hpack to \scratchdimen{\hss\raise\lowmidhighparameter\c!up \box\plussix \hss}
279 \wd\plustwo \zeropoint
280 \wd\plusfour\zeropoint
281 \box\plusfour
282 \box\plustwo
283 \box\plussix
284 \dostoptagged
285 \egroup}
286
287\permanent\protected\def\lomihi {\typo_scripts_lowmidhigh[]}
288\permanent\protected\def\himilo#1#2#3{\typo_scripts_lowmidhigh[]{#3}{#2}{#1}}
289
290\protect \endinput
291 |