1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16\writestatus{loading}{ConTeXt Spacing Macros Grid Snapping}
17
18\unprotect
19
20
21
22
23\installcorenamespace{lastnodepusher}
24
25\permanent\let\poplastnode\relax
26
27\permanent\protected\def\pushlastnode
28 {\csname\??lastnodepusher
29 \ifcsname\??lastnodepusher\the\lastnodetype\endcsname
30 \the\lastnodetype
31 \else
32 \s!unknown
33 \fi
34 \endcsname}
35
36\defcsname\??lastnodepusher\the\kernnodecode\endcsname
37 {\enforced\permanent\protected\edef\poplastnode{\kern\the\lastkern\relax}
38 \kern\lastkern}
39
40\defcsname\??lastnodepusher\the\gluenodecode\endcsname
41 {\enforced\permanent\protected\edef\poplastnode{\vskip\the\lastskip\relax}
42 \vskip\lastskip}
43
44\defcsname\??lastnodepusher\the\penaltynodecode\endcsname
45 {\enforced\permanent\protected\edef\poplastnode{\penalty\the\lastpenalty\relax}
46 \nobreak}
47
48\defcsname\??lastnodepusher\s!unknown\endcsname
49 {\enforced\permanent\let\poplastnode\relax}
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\newdimension\d_spac_lines_correction_before
105\newdimension\d_spac_lines_correction_after
106
107\newbox \b_spac_lines_correction_before
108\newbox \b_spac_lines_correction_after
109
110\def\spac_lines_initialize_corrections
111 {\setbox\b_spac_lines_correction_before\hpack{\setstrut\strut}
112 \setbox\b_spac_lines_correction_after \hbox {(}
113 \d_spac_lines_correction_before\dimexpr\ht\b_spac_lines_correction_before\ht\b_spac_lines_correction_after\relax
114 \d_spac_lines_correction_after \dimexpr\dp\b_spac_lines_correction_before\dp\b_spac_lines_correction_after\relax
115 \ifdim\d_spac_lines_correction_before<\zeropoint\d_spac_lines_correction_before\zeropoint\fi
116 \ifdim\d_spac_lines_correction_after <\zeropoint\d_spac_lines_correction_after \zeropoint\fi}
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136\permanent\protected\def\dotopbaselinecorrection{\expandafter\blank\expandafter[\the\d_spac_lines_correction_before]}
137\permanent\protected\def\dobotbaselinecorrection{\expandafter\blank\expandafter[\the\d_spac_lines_correction_after ]}
138
139\permanent\def\showbaselinecorrection
140 {\enforced\permanent\protected\def\dobaselinecorrection
141 {\bgroup
142 \ifdim\prevdepth>\zeropoint
143 \kern\prevdepth
144 \fi
145 \setbox\scratchbox\emptyhbox
146 \wd\scratchbox\hsize
147 \dp\scratchbox\strutdp
148 \nointerlineskip
149 \forgetall
150 \ruledvpack{\box\scratchbox}
151 \egroup
152 \prevdepth\strutdp}
153 \enforced\permanent\protected\def\dotopbaselinecorrection{\hrule\s!height\d_spac_lines_correction_before}
154 \enforced\permanent\protected\def\dobotbaselinecorrection{\hrule\s!height\d_spac_lines_correction_after }}
155
156
157
158
159
160
161\permanent\protected\def\baselinecorrection
162 {\endgraf
163 \ifvmode
164 \ifdim\prevdepth<\maxdimen
165 \ifdim\prevdepth<\zeropoint \else
166 \ifdim\prevdepth<\strutdepth \relax
167 \pushlastnode
168 \dobaselinecorrection
169 \poplastnode
170 \fi
171 \fi
172 \fi
173 \fi}
174
175\permanent\protected\def\pagebaselinecorrection
176 {\ifdim\pagegoal<\maxdimen
177 \ifdim\pagetotal>\lineheight
178 \scratchdimen\pagetotal
179 \advanceby\scratchdimen\lineheight
180 \ifdim\scratchdimen<\pagegoal
181 \baselinecorrection
182 \fi
183 \fi
184 \fi}
185
186\permanent\protected\def\startbaselinecorrection
187 {\bgroup
188 \enforced\let\stopbaselinecorrection\egroup
189 \ifcase\baselinecorrectionmode
190 \or
191 \baselinecorrection
192 \ifvmode
193 \setbox\scratchbox\vbox\bgroup\ignorespaces
194 \enforced\let\stopbaselinecorrection\donormalstopbaselinecorrection
195 \fi
196 \or
197 \or
198 \baselinecorrection
199 \ifvmode
200 \setbox\scratchbox\vbox\bgroup\ignorespaces
201 \enforced\let\stopbaselinecorrection\doforcedstopbaselinecorrection
202 \fi
203 \fi}
204
205\permanent\let\stopbaselinecorrection\relax
206
207\permanent\protected\def\donormalstopbaselinecorrection
208 {\egroup
209 \topbaselinecorrection
210 \box\scratchbox
211 \botbaselinecorrection
212 \egroup}
213
214\permanent\protected\def\doforcedstopbaselinecorrection
215 {\egroup
216 \forcedtopbaselinecorrection
217 \box\scratchbox
218 \forcedbotbaselinecorrection
219 \egroup}
220
221
222
223
224
225\setnewconstant\baselinecorrectionmode\plusone
226
227\permanent\protected\def\onbaselinecorrection {\baselinecorrectionmode\plusone }
228\permanent\protected\def\offbaselinecorrection {\baselinecorrectionmode\plustwo }
229\permanent\protected\def\forcebaselinecorrection{\baselinecorrectionmode\plusthree}
230
231
232
233
234
235
236\permanent\protected\def\topbaselinecorrection
237 {\ifvmode \ifdim\pagegoal<\maxdimen
238 \forcedtopbaselinecorrection
239 \fi \fi}
240
241
242
243
244
245
246
247
248
249
250
251\permanent\protected\def\botbaselinecorrection
252 {\ifvmode
253 \bgroup
254 \spac_lines_initialize_corrections
255 \dobotbaselinecorrection
256 \allowbreak
257 \prevdepth\strutdp
258 \egroup
259 \fi}
260
261
262
263
264
265
266
267
268\permanent\protected\def\forcedtopbaselinecorrection
269 {\ifvmode
270 \bgroup
271 \spac_lines_initialize_corrections
272 \vspacing[\v!white]
273
274 \dotopbaselinecorrection
275 \egroup
276 \fi}
277
278\aliased\let\forcedbotbaselinecorrection\botbaselinecorrection
279
280\permanent\protected\def\dobaselinecorrection
281 {\ifdim\prevdepth>\zeropoint
282 \vspacing[\the\dimexpr\prevdepth\strutdp\relax]
283 \else
284 \vspacing[\the\dimexpr\strutdp\relax]
285 \fi
286 \prevdepth\strutdp}
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\permanent\protected\def\checkprevdepth
320 {\endgraf
321 \ifvmode
322 \ifdim\prevdepth<\maxdimen
323 \ifdim\prevdepth<\zeropoint \else
324 \ifdim\prevdepth<\strutdepth \relax
325 \clf_checkstrutdepth\strutdp
326 \fi
327 \fi
328 \fi
329 \fi}
330
331\aliased\let\normalstartbaselinecorrection\startbaselinecorrection
332
333\pushoverloadmode
334
335\permanent\protected\def\startbaselinecorrection
336 {\ifgridsnapping
337 \snaptogrid[\v!normal]\vbox\bgroup
338 \enforced\let\stopbaselinecorrection\egroup
339 \else
340 \normalstartbaselinecorrection
341 \fi}
342
343\popoverloadmode
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\protect \endinput
378 |