1
2
3
4
5
6
7
8
9
10
11
12
13
14\writestatus{loading}{ConTeXt Spacing Macros Vertical}
15
16\unprotect
17
18\newgluespec\bodyfontlineheight
19\newdimen \bodyfontstrutheight
20\newdimen \bodyfontstrutdepth
21
22\newgluespec\globalbodyfontlineheight
23\newdimen \globalbodyfontstrutheight
24\newdimen \globalbodyfontstrutdepth
25
26\newgluespec \s_spac_vspacing_predefined
27\newdimension\d_spac_overlay
28\newinteger \c_spac_vspacing_ignore_parskip
29
30
31
32
33
34\registerctxluafile{spacver}{autosuffix}
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
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\newif\iflocalinterlinespace
77
78\newgluespec\s_spac_vspacing_temp \s_spac_vspacing_temp\bigskipamount
79
80\mutable\def\skipfactor {.75}
81\mutable\def\skipgluefactor{.25}
82
83\permanent\def\normalskipamount
84 {\openlineheight
85 \ifgridsnapping \orelse \ifconditional\c_spac_whitespace_flexible
86 \s!plus \skipgluefactor\openlineheight
87 \s!minus\skipgluefactor\openlineheight
88 \fi
89 \relax}
90
91\ifdefined\bodyfontinterlinespace \else
92 \lettonothing\bodyfontinterlinespace
93\fi
94
95
96
97
98
99
100
101
102
103
104\permanent\protected\def\presetnormallineheight
105 {\edef\normallineheight{\interlinespaceparameter\c!line}
106 \iflocalinterlinespace \else
107 \edef\m_spac_normallineheight{\bodyfontinterlinespace}
108 \ifempty\m_spac_normallineheight
109 \orelse\ifchkdimension\m_spac_normallineheight\or
110 \let\normallineheight\m_spac_normallineheight
111 \else
112 \edef\normallineheight{\todimension\m_spac_normallineheight\dimexpr\fontbody\relax}
113 \fi
114 \fi}
115
116\permanent\protected\def\setupspecifiedinterlinespace[#S#1]
117 {\setupcurrentinterlinespace[#1]
118 \spac_linespacing_setup_specified_interline_space}
119
120\def\spac_linespacing_setup_specified_interline_space
121 {\edef\strutheightfactor {\interlinespaceparameter\c!height }
122 \edef\strutdepthfactor {\interlinespaceparameter\c!depth }
123 \edef\minimumstrutheight {\interlinespaceparameter\c!minheight}
124 \edef\minimumstrutdepth {\interlinespaceparameter\c!mindepth }
125 \edef\minimumlinedistance {\interlinespaceparameter\c!distance }
126 \edef\normallineheight {\interlinespaceparameter\c!line }
127 \edef\topskipfactor {\interlinespaceparameter\c!top }
128 \edef\ntopskipfactor {\interlinespaceparameter\c!ntop }
129 \edef\maxdepthfactor {\interlinespaceparameter\c!bottom }
130 \edef\m_spac_vertical_baseline_stretch_factor{\interlinespaceparameter\c!stretch}
131 \edef\m_spac_vertical_baseline_shrink_factor {\interlinespaceparameter\c!shrink }
132
133 \ifx\topskipfactor\v!height
134 \let\topskipfactor\strutheightfactor
135 \fi
136 \setfontparameters
137 \updateraggedskips}
138
139\installcorenamespace{interlinespacerelative}
140
141\aliased\let\setrelativeinterlinespace\relax
142
143\mutable\lettonothing\currentrelativeinterlinespace
144
145\defcsname\??interlinespacerelative\v!on \endcsname{\oninterlineskip}
146\defcsname\??interlinespacerelative\v!off \endcsname{\offinterlineskip}
147\defcsname\??interlinespacerelative\v!reset\endcsname{\enforced\lettonothing\currentrelativeinterlinespace
148 \enforced\let\setrelativeinterlinespace\relax
149 \setfontparameters}
150\defcsname\??interlinespacerelative\v!auto \endcsname{\enforced\let\setrelativeinterlinespace\spac_linespacing_set_relative_interlinespace}
151
152\def\spac_linespacing_set_specified_relative_interlinespace#1
153 {\doifelsedimenstring{#1}
154 {\setupspecifiedinterlinespace[\c!line=#1]}
155 {\assignvalue{#1}\currentrelativeinterlinespace{1.00}{1.25}{1.50}
156 \spacing\currentrelativeinterlinespace}}
157
158\permanent\protected\def\setuprelativeinterlinespace[#1]
159 {\processcommalist[#1]\spac_linespacing_setup_relative_interlinespace}
160
161\def\spac_linespacing_setup_relative_interlinespace#1
162 {\ifcsname\??interlinespacerelative#1\endcsname
163 \lastnamedcs
164 \else
165 \spac_linespacing_set_specified_relative_interlinespace{#1}
166 \fi}
167
168\permanent\protected\def\spac_linespacing_set_relative_interlinespace
169 {\ifempty\currentrelativeinterlinespace\else
170 \spacing\currentrelativeinterlinespace
171 \fi}
172
173\protected\def\spac_linespacing_setup_use
174 {\ifcsname\namedinterlinespacehash\m_spac_interlinespace\s!parent\endcsname
175 \let\currentinterlinespace\m_spac_interlinespace
176 \spac_linespacing_setup_specified_interline_space
177
178
179 \fi}
180
181\permanent\protected\def\useinterlinespaceparameter#1
182 {\edef\m_spac_interlinespace{#1\c!interlinespace}
183 \ifempty\m_spac_interlinespace \else
184 \spac_linespacing_setup_use
185 \fi}
186
187\newtoks\everysetupglobalinterlinespace
188\newtoks\everysetuplocalinterlinespace
189
190\newconditional\interlinespaceisset
191
192\installcorenamespace{interlinespace}
193
194\installcommandhandler \??interlinespace {interlinespace} \??interlinespace
195
196\installmacrostack\currentinterlinespace
197
198\permanent\overloaded\tolerant\protected\def\setupinterlinespace[#S#1]
199 {\ifarguments
200 \interlinespaceisset\conditionaltrue
201 \spac_linespacing_synchronize_local
202 \else
203 \interlinespaceisset\conditionaltrue
204 \ifcsname\namedinterlinespacehash{#1}\s!parent\endcsname
205 \cdef\currentinterlinespace{#1}
206 \spac_linespacing_setup_specified_interline_space
207
208 \else
209 \spac_linespacing_setup_specified_or_relative[#1]
210 \fi
211 \fi}
212
213\def\spac_linespacing_setup_specified_or_relative[#S#1]
214 {\doifelseassignment{#1}\setupspecifiedinterlinespace\setuprelativeinterlinespace[#1]
215 \expandtoks\iflocalinterlinespace\everysetuplocalinterlinespace\else\everysetupglobalinterlinespace\fi}
216
217\def\spac_linespacing_synchronize_local
218 {\localinterlinespacetrue
219 \setfontparameters
220 \updateraggedskips
221 \expandtoks\everysetuplocalinterlinespace
222 \localinterlinespacefalse}
223
224\permanent\protected\def\dosetupcheckedinterlinespace#1
225 {\edef\p_spac_checked_interlinespace{#1}
226 \ifempty\p_spac_checked_interlinespace
227 \spac_linespacing_synchronize_local
228 \orelse\ifcsname\namedinterlinespacehash\p_spac_checked_interlinespace\s!parent\endcsname
229 \push_macro_currentinterlinespace
230 \let\currentinterlinespace\p_spac_checked_interlinespace
231 \spac_linespacing_setup_specified_interline_space
232 \iflocalinterlinespace
233 \expandtoks\everysetuplocalinterlinespace
234 \else
235 \localinterlinespacetrue
236 \expandtoks\everysetuplocalinterlinespace
237 \localinterlinespacefalse
238 \fi
239 \pop_macro_currentinterlinespace
240 \else
241 \normalexpanded{\noexpand\doifelseassignment{\p_spac_checked_interlinespace}
242 \setupspecifiedinterlinespace\setuprelativeinterlinespace[\p_spac_checked_interlinespace]}
243 \iflocalinterlinespace
244 \expandtoks\everysetuplocalinterlinespace
245 \else
246 \localinterlinespacetrue
247 \expandtoks\everysetuplocalinterlinespace
248 \localinterlinespacefalse
249 \fi
250 \fi}
251
252\permanent\protected\def\setuplocalinterlinespace[#S#1]
253 {\localinterlinespacetrue
254 \push_macro_currentinterlinespace
255 \setupinterlinespace[#1]
256 \pop_macro_currentinterlinespace
257 \localinterlinespacefalse}
258
259\aliased\let\switchtointerlinespace\setuplocalinterlinespace
260
261
262
263\newgluespec \s_spac_lastskip
264\newdimension\d_spac_prevdepth
265\newinteger \c_spac_spacefactor
266
267
268
269
270
271\permanent\def\doifoutervmode
272 {\unless\ifvmode
273 \expandafter\gobbleoneargument
274 \orelse\ifinner
275 \expandafter\gobbleoneargument
276 \else
277 \expandafter\firstofoneargument
278 \fi}
279
280\permanent\protected\def\dosomebreak#1
281 {\doifoutervmode
282 {\s_spac_lastskip\lastskip
283 \removelastskip
284 #1\relax
285 \ifzeropt\s_spac_lastskip
286
287 \else
288 \vskip\s_spac_lastskip
289 \fi}}
290
291\permanent\protected\def\packed
292 {\nointerlineskip}
293
294\permanent\protected\def\godown[#1]
295 {\relax
296 \ifhmode\endgraf\fi
297 \ifvmode\nointerlineskip\vskip#1\relax\fi}
298
299\permanent\protected\def\smallskip{\vskip\smallskipamount}
300\permanent\protected\def\medskip {\vskip\medskipamount}
301\permanent\protected\def\bigskip {\vskip\bigskipamount}
302
303\permanent\protected\def\smallbreak
304 {\par
305 \ifvmode\ifdim\lastskip<\smallskipamount
306 \removelastskip
307 \penalty\plusfifty
308 \smallskip
309 \fi\fi}
310
311\permanent\protected\def\medbreak
312 {\par
313 \ifvmode\ifdim\lastskip<\medskipamount
314 \removelastskip
315 \penalty\plusonehundred
316 \medskip
317 \fi\fi}
318
319\permanent\protected\def\bigbreak
320 {\par
321 \ifvmode\ifdim\lastskip<\bigskipamount
322 \removelastskip
323 \penalty\plustwohundred
324 \bigskip
325 \fi\fi}
326
327\permanent\protected\def\break {\penalty\plustenthousand}
328\permanent\protected\def\nobreak {\penalty \plustenthousand}
329\permanent\protected\def\allowbreak{\penalty \zerocount}
330
331\permanent\protected\def\goodbreak {\par\ifvmode\penalty\plusfivehundred\relax\fi}
332\permanent\protected\def\filbreak {\par\ifvmode\vfil\penalty\plustwohundred\vfilneg\fi}
333
334
335
336\permanent\protected\def\vglue {\afterassignment\spac_helpers_vglue_indeed\s_spac_lastskip=}
337\permanent\protected\def\hglue {\afterassignment\spac_helpers_hglue_indeed\s_spac_lastskip=}
338\permanent\protected\def\topglue{\par\ifvmode\nointerlineskip\vglue\topskip\vglue\fi}
339
340\def\spac_helpers_vglue_indeed
341 {\par
342 \ifvmode
343 \d_spac_prevdepth\prevdepth
344 \hrule\s!height\zeropoint
345 \nobreak
346 \vskip\s_spac_lastskip
347 \prevdepth\d_spac_prevdepth
348 \fi}
349
350\def\spac_helpers_hglue_indeed
351 {\dontleavehmode
352 \c_spac_spacefactor\spacefactor
353 \vrule\s!width\zeropoint
354 \nobreak
355 \hskip\s_spac_lastskip
356 \spacefactor\c_spac_spacefactor}
357
358
359
360\pushoverloadmode
361
362\permanent\overloaded\protected\def\removelastskip
363 {\ifvmode\ifzeropt\lastskip\else\vskip\lastskip\fi\fi}
364
365\popoverloadmode
366
367
368
369
370\installcorenamespace{whitespacemethod}
371
372\newgluespec \s_spac_whitespace_parskip
373\newconditional\c_spac_whitespace_flexible \c_spac_whitespace_flexible\conditionaltrue
374\newconstant \c_spac_whitespace_grid_mode
375
376
377\let\v_spac_whitespace_current\v!none
378
379\permanent\tolerant\protected\def\setupwhitespace[#1]
380 {\ifarguments
381 \spac_whitespace_setup_nop
382 \orelse\ifempty{#1}
383 \spac_whitespace_setup_nop
384 \else
385 \edef\v_spac_whitespace_current{#1}
386 \spac_whitespace_setup
387 \fi}
388
389\permanent\protected\def\spac_whitespace_setup_nop
390 {\ifx\v_spac_whitespace_current\v!none\else
391 \spac_whitespace_setup
392 \fi}
393
394\aliased\let\synchronizewhitespace\spac_whitespace_setup_nop
395
396\def\spac_whitespace_setup
397 {\ifcsname\??whitespacemethod\v_spac_whitespace_current\endcsname
398 \lastnamedcs
399 \else
400 \expandafter\processcommalist\expandafter[\v_spac_whitespace_current]\spac_whitespace_setup_method
401 \fi\relax
402 \ifgridsnapping
403 \spac_whitespace_setup_grid
404 \else
405 \spac_whitespace_setup_normal
406 \fi
407 \parskip\s_spac_whitespace_parskip}
408
409\def\spac_whitespace_setup_normal
410 {\ifconditional\c_spac_whitespace_flexible \else
411 \s_spac_whitespace_parskip\plusone\s_spac_whitespace_parskip
412 \fi}
413
414\def\spac_whitespace_setup_grid
415 {\c_spac_whitespace_flexible\conditionalfalse
416 \ifdim\s_spac_whitespace_parskip>\zeropoint
417 \s_spac_whitespace_parskip
418 \ifcase\c_spac_whitespace_grid_mode
419 \baselineskip
420 \or
421 \ifdim\scratchdimen=\baselineskip
422 \baselineskip
423 \else
424 \numexpr\s_spac_whitespace_parskip\dimexpr.5\lineheight\relax\relax\dimexpr.5\lineheight\relax
425 \fi
426 \else
427 \baselineskip
428 \fi
429 \fi}
430
431\permanent\protected\def\installwhitespacemethod#1#2
432 {\defcsname\??whitespacemethod#1\endcsname{#2}}
433
434\installwhitespacemethod \v!fix {}
435\installwhitespacemethod \v!fixed {\c_spac_whitespace_flexible\conditionalfalse}
436\installwhitespacemethod \v!flexible {\c_spac_whitespace_flexible\conditionaltrue}
437
438\installwhitespacemethod \v!line {\s_spac_whitespace_parskip \baselineskip}
439\installwhitespacemethod \v!halfline {\s_spac_whitespace_parskip .5\baselineskip}
440\installwhitespacemethod \v!quarterline {\s_spac_whitespace_parskip.25\baselineskip}
441\installwhitespacemethod \v!none {\s_spac_whitespace_parskip \zeroskip}
442\installwhitespacemethod \v!big {\s_spac_whitespace_parskip \bigskipamount}
443\installwhitespacemethod \v!medium {\s_spac_whitespace_parskip \medskipamount}
444\installwhitespacemethod \v!small {\s_spac_whitespace_parskip \smallskipamount}
445
446\installwhitespacemethod \s!default {\spac_whitespace_setup_nop}
447
448\def\spac_whitespace_setup_method#1
449 {\ifcsname\??whitespacemethod#1\endcsname
450 \lastnamedcs
451 \else
452 \s_spac_whitespace_parskip#1
453 \fi\relax}
454
455\permanent\protected\def\forgetparskip
456 {\s_spac_whitespace_parskip\zeroskip
457 \parskip\zeroskip
458 \let\v_spac_whitespace_current\v!none}
459
460\appendtoks
461 \forgetparskip
462\to \everyforgetall
463
464
465
466
467
468
469\permanent\protected\def\nowhitespace{\directcheckedvspacing\v!nowhite}
470\permanent\protected\def\whitespace {\directcheckedvspacing\v!white}
471
472\setupwhitespace
473 [\v!none]
474
475
476
477
478
479\newconditional\c_spac_packed_blank \c_spac_packed_blank\conditionaltrue
480\newinteger \c_spac_packed_level
481
482\permanent\tolerant\protected\def\startpacked[#1]
483 {\global\advanceby\c_spac_packed_level\plusone
484 \par
485 \ifnum\c_spac_packed_level=\plusone \ifvmode
486 \begingroup
487 \whitespace
488 \directcheckedvspacing\v!disable
489 \ifcstok{#1}\v!blank
490 \c_spac_packed_blank\conditionaltrue
491 \else
492 \c_spac_packed_blank\conditionalfalse
493 \fi
494 \setupwhitespace[\v!none]
495 \fi \fi}
496
497\permanent\protected\def\stoppacked
498 {\par
499 \ifnum\c_spac_packed_level=\plusone \ifvmode
500 \endgroup
501 \fi \fi
502 \global\advanceby\c_spac_packed_level\minusone}
503
504\permanent\protected\def\startunpacked
505 {\directdefaultvspacing
506 \begingroup}
507
508\permanent\protected\def\stopunpacked
509 {\endgroup
510 \directdefaultvspacing}
511
512
513
514
515
516
517
518
519\installcorenamespace{linesaround}
520
521\let\spac_lines_vbox\vbox
522
523\installtextracker
524 {linecorrection.boxes}
525 {\enforced\let\spac_lines_vbox\ruledvbox}
526 {\enforced\let\spac_lines_vbox\vbox}
527
528\let\v_spac_lines_around_action_set\relax
529
530\lettonothing\spac_lines_action_around_before
531\lettonothing\spac_lines_action_around_after
532
533\newconstant\c_spac_lines_correction_mode
534
535\installcorenamespace{linecorrection}
536
537\installsetuponlycommandhandler \??linecorrection {linecorrection}
538
539\permanent\tolerant\protected\def\startlinecorrection [#S#1]{\spac_lines_start_correction\plusone{#1}}
540\permanent\tolerant\protected\def\startlocallinecorrection[#S#1]{\spac_lines_start_correction\plustwo{#1}}
541
542\permanent\protected\def\spac_lines_start_correction_box
543 {\setbox\scratchbox\spac_lines_vbox\bgroup
544 \ifcase\c_spac_lines_correction_mode
545
546 \or
547
548 \or
549
550 \setlocalhsize
551 \hsize\localhsize
552 \forgetbothskips
553 \fi
554 \ignorespaces}
555
556\permanent\protected\def\spac_lines_stop_correction_box
557 {\removeunwantedspaces
558 \egroup}
559
560\permanent\protected\def\spac_lines_start_correction#1#2
561 {\endgraf
562 \begingroup
563 \c_spac_lines_correction_mode#1
564
565 \ifhastok={#2}
566 \setupcurrentlinecorrection[#2]
567 \def\spac_lines_action_around_before{\linecorrectionparameter\c!before}
568 \def\spac_lines_action_around_after {\linecorrectionparameter\c!after}
569 \orelse\ifempty{#2}
570 \def\spac_lines_action_around_before{\linecorrectionparameter\c!before}
571 \def\spac_lines_action_around_after {\linecorrectionparameter\c!after}
572 \orelse\ifcstok{#2}\v!blank
573 \def\spac_lines_action_around_before{\blank}
574 \let\spac_lines_action_around_after \spac_lines_action_around_before
575 \else
576 \def\spac_lines_action_around_before{\blank[#2]}
577 \let\spac_lines_action_around_after \spac_lines_action_around_before
578 \fi
579 \ifgridsnapping
580 \spac_lines_start_correction_ongrid
581 \else
582 \spac_lines_start_correction_normal
583 \fi}
584
585\permanent\protected\def\spac_lines_stop_correction
586 {\ifgridsnapping
587 \spac_lines_stop_correction_ongrid
588 \else
589 \spac_lines_stop_correction_normal
590 \fi
591 \endgroup}
592
593\permanent\protected\def\spac_lines_start_correction_normal
594 {\spac_lines_action_around_before
595 \d_spac_prevdepth\prevdepth
596 \spac_lines_initialize_corrections
597 \offbaselinecorrection
598 \spac_lines_start_correction_box}
599
600\newconstant\linecorrectionmode
601
602
603
604\permanent\protected\def\spac_lines_stop_correction_normal
605 {\spac_lines_stop_correction_box
606 \ifnum\linecorrectionmode=\plusone
607 \forcestrutdepth
608 \iftrue
609 \penalty\zerocount
610 \else
611
612 \pageboundary\plustenthousand
613
614 \fi
615 \else
616 \directcheckedvspacing\v!nowhite
617 \ifdim\parskip>\zeropoint
618
619 \orelse\ifdim\d_spac_prevdepth<\maxdimen
620 \unless\ifdim\d_spac_prevdepth<\zeropoint
621 \ifdim\d_spac_prevdepth<\strutdp \relax
622 \pushlastnode
623 \ifdim\d_spac_prevdepth>\zeropoint
624 \kern\d_spac_prevdepth
625 \fi
626 \kern\strutdp
627 \prevdepth\strutdp
628 \poplastnode
629 \fi
630 \fi
631 \fi
632 \fi
633 \ifdim\pagegoal<\maxdimen
634
635 \directcheckedvspacing{\v!white,\the\d_spac_lines_correction_before}
636 \fi
637 \nointerlineskip
638 \noindent
639 \ifcase\c_spac_lines_correction_mode
640
641 \or
642
643 \hskip\leftskip
644 \or
645
646 \fi
647 \box\scratchbox
648 \endgraf
649
650
651
652
653
654 \directcheckedvspacing{\v!white,\the\d_spac_lines_correction_after}
655
656 \prevdepth\strutdp
657 \spac_lines_action_around_after}
658
659
660
661\permanent\protected\def\spac_lines_start_correction_ongrid
662 {\spac_lines_action_around_before
663 \d_spac_prevdepth\prevdepth
664 \spac_lines_initialize_corrections
665 \offbaselinecorrection
666 \spac_lines_start_correction_box}
667
668\permanent\protected\def\spac_lines_stop_correction_ongrid
669 {\spac_lines_stop_correction_box
670 \directcheckedvspacing\v!white
671 \spac_lines_action_around_before
672 \snaptogrid\hpack{\box\scratchbox}
673 \directcheckedvspacing\v!white
674 \spac_lines_action_around_after}
675
676\aliased\let\stoplinecorrection \spac_lines_stop_correction
677\aliased\let\stoplocallinecorrection\spac_lines_stop_correction
678
679
680
681\permanent\protected\def\correctwhitespace
682 {\dowithnextboxcs\correctwhitespacefinish\vbox}
683
684\permanent\protected\def\correctwhitespacefinish
685 {\startbaselinecorrection
686 \flushnextbox
687 \stopbaselinecorrection}
688
689\permanent\protected\def\verticalstrut {\vpack{\hsize\zeropoint\forgetall\strut}}
690\permanent\protected\def\horizontalstrut{\hpack {\strut}}
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722\newdimension\strutdimen
723\newdimension\lineheight
724\newdimension\openlineheight
725\newdimension\openstrutheight
726\newdimension\openstrutdepth
727\newdimension\topskipgap
728
729\newdimension\strutheight
730\newdimension\strutdepth
731\newdimension\struttotal
732\newdimension\strutwidth
733
734\let\m_spac_vertical_baseline_stretch_factor \zerocount
735\let\m_spac_vertical_baseline_shrink_factor \zerocount
736
737\mutable\def\strutheightfactor {.72}
738\mutable\def\strutdepthfactor {.28}
739\mutable\def\baselinefactor {2.8}
740\mutable\def\topskipfactor {1.0}
741\mutable\def\maxdepthfactor {0.5}
742\mutable\let\ntopskipfactor \minusone
743
744\mutable\def\minimumstrutheight {\zeropoint}
745\mutable\def\minimumstrutdepth {\zeropoint}
746
747\mutable\def\normallineheight {\baselinefactor\exheight}
748\mutable\def\minimumlinedistance {\lineskip}
749
750\mutable\let\spacingfactor \plusone
751
752\mutable\def\systemtopskipfactor {\topskipfactor}
753\mutable\def\systemmaxdepthfactor{\maxdepthfactor}
754
755\ifdefined\globalbodyfontsize \else
756 \newdimension\globalbodyfontsize
757 \globalbodyfontsize=12pt
758\fi
759
760\ifdefined\normalizedbodyfontsize \else
761 \def\normalizedbodyfontsize{12pt}
762\fi
763
764\permanent\protected\def\topskipcorrection
765 {\simpletopskipcorrection
766 \vskip\struttotal
767 \verticalstrut}
768
769\permanent\protected\def\simpletopskipcorrection
770 {\ifdim\topskip>\openstrutheight
771
772 \vskip\topskip
773 \vskip\openstrutheight
774 \fi}
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804\permanent\protected\def\settopskip
805 {\topskip
806 \ifgridsnapping
807 \zeroskip
808 \initialpageskip\zeroskip
809 \else
810 \systemtopskipfactor\globalbodyfontsize
811 \relax
812 \initialpageskip\zeropoint
813 \ifcase\bottomraggednessmode
814 \s!plus \ntopskipfactor\openlineheight
815 \fi
816 \relax
817 \fi
818 \topskipgap\topskip
819 \advanceby\topskipgap \openstrutheight\relax
820 \ifdim\minimumstrutheight>\zeropoint
821 \ifdim\topskip<\minimumstrutheight
822 \topskip\minimumstrutheight\relax
823 \fi
824 \else
825 \ifdim\topskip<\strutheightfactor\openlineheight
826 \topskip\strutheightfactor\openlineheight\relax
827 \fi
828 \fi}
829
830\permanent\protected\def\setmaxdepth
831 {\maxdepth\systemmaxdepthfactor\globalbodyfontsize}
832
833\newgluespec \usedbaselineskip
834\newgluespec \usedlineskip
835\newdimension\usedlineskiplimit
836
837\permanent\protected\def\normalbaselines
838 {\baselineskip \usedbaselineskip
839 \lineskip \usedlineskip
840 \lineskiplimit\usedlineskiplimit}
841
842
843
844
845
846
847\permanent\protected\def\flexiblebaselines
848 {\baselineskip 1\usedbaselineskip \s!plus 1\s!fill
849 \lineskip \usedlineskip
850 \lineskiplimit \usedlineskiplimit}
851
852\permanent\protected\def\setnormalbaselines
853 {\ifdim\normallineheight>\zeropoint
854 \lineheight\normallineheight
855 \fi
856 \openlineheight\spacingfactor\lineheight
857 \openstrutheight \ifdim\minimumstrutheight>\zeropoint
858 \minimumstrutheight
859 \else
860 \strutheightfactor\openlineheight
861 \fi
862 \openstrutdepth \ifdim\minimumstrutdepth>\zeropoint
863 \minimumstrutdepth
864 \else
865 \strutdepthfactor \openlineheight
866 \fi
867 \ifdim\dimexpr\minimumstrutdepth\minimumstrutheight\relax>\zeropoint
868 \openlineheight\dimexpr\openstrutheight\openstrutdepth\relax
869 \fi
870 \usedbaselineskip\openlineheight
871 \ifgridsnapping\else
872 \s!plus \m_spac_vertical_baseline_stretch_factor\openlineheight
873 \s!minus\m_spac_vertical_baseline_shrink_factor \openlineheight
874 \fi
875 \usedlineskip\minimumlinedistance\relax
876 \usedlineskiplimit\zeropoint\relax
877 \normalbaselines}
878
879\permanent\protected\def\spacing#1
880 {\ifgridsnapping
881 \let\spacingfactor\plusone
882 \else
883 \permanent\edef\spacingfactor{#1}
884 \fi
885 \edef\systemtopskipfactor {\thewithoutunit\dimexpr#1\dimexpr\topskipfactor \points}
886 \edef\systemmaxdepthfactor{\thewithoutunit\dimexpr#1\dimexpr\maxdepthfactor\points}
887 \setnormalbaselines
888 \setstrut}
889
890
891
892
893\permanent\protected\def\forgetverticalstretch
894 {\let\spacingfactor \plusone
895 \let\systemtopskipfactor \topskipfactor
896 \let\systemmaxdepthfactor\maxdepthfactor
897 \setnormalbaselines
898 \setstrut}
899
900\appendtoks
901 \forgetverticalstretch
902\to \everyforgetall
903
904
905
906
907
908
909
910
911
912\aliased\let\restoreinterlinespace\relax
913
914\permanent\protected\def\saveinterlinespace
915 {\enforced\permanent\protected\edef\restoreinterlinespace
916 {\lineheight \the\lineheight
917 \openstrutheight \the\openstrutheight
918 \openstrutdepth \the\openstrutdepth
919 \openlineheight \the\openlineheight
920 \usedbaselineskip \the\usedbaselineskip
921 \usedlineskip \the\usedlineskip
922 \usedlineskiplimit \the\usedlineskiplimit
923 \noexpand\def\noexpand\normallineheight{\the\dimexpr\normallineheight}
924 \noexpand\normalbaselines}}
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940\newbox\b_strut_box
941\newbox\b_strut_tmp
942
943\permanent\protected\def\strutbox
944 {\beginlocalcontrol
945 \setbox\b_strut_tmp\hpack{\normalsrule\s!height\strutht\s!depth\strutdp}
946 \endlocalcontrol
947 \b_strut_tmp}
948
949
950
951
952
953
954
955\permanent\protected\def\setstrut
956 {\ifgridsnapping
957 \setstrutgridyes
958 \else
959 \setstrutgridnop
960 \fi}
961
962\permanent\protected\def\setstrutgridyes
963 {\strutht\spacingfactor\dimexpr
964 \ifdim\minimumstrutheight>\zeropoint
965 \minimumstrutheight
966 \else
967 \strutheightfactor\dimexpr\normallineheight
968 \fi
969 \relax
970 \strutdp\dimexpr
971 \ifdim\minimumstrutdepth>\zeropoint
972 \minimumstrutdepth
973 \else
974 \normallineheight\strutht
975 \fi
976 \relax
977 \dosetstrut}
978
979\permanent\protected\def\setstrutgridnop
980 {\strutht\spacingfactor\dimexpr
981 \ifdim\minimumstrutheight>\zeropoint
982 \minimumstrutheight
983 \else
984 \strutheightfactor\dimexpr\normallineheight
985 \fi
986 \relax
987 \strutdp\spacingfactor\dimexpr
988 \ifdim\minimumstrutdepth>\zeropoint
989 \minimumstrutdepth
990 \else
991 \strutdepthfactor\dimexpr\normallineheight
992 \fi
993 \relax
994 \dosetstrut}
995
996\permanent\protected\def\setcharstrut#1
997 {\setbox\b_strut_box\hbox{#1}
998 \strutht\ht\b_strut_box
999 \strutdp\dp\b_strut_box
1000 \dosetstrut}
1001
1002\permanent\protected\def\settightstrut
1003 {\setcharstrut{(}}
1004
1005\permanent\protected\def\setfontstrut
1006 {\setcharstrut{(gplQT}}
1007
1008\permanent\protected\def\setcapstrut
1009 {\setcharstrut{Q}}
1010
1011
1012
1013\permanent\protected\def\charhtstrut
1014 {\begingroup
1015 \setcharstrut{GJY}
1016 \normalsrule
1017 \s!depth \zeropoint
1018 \s!height\strutht
1019 \endgroup}
1020
1021\permanent\protected\def\chardpstrut
1022 {\begingroup
1023 \setcharstrut{gjy}
1024 \normalsrule
1025 \s!depth \strutdp
1026 \s!height\zeropoint
1027 \endgroup}
1028
1029
1030
1031
1032
1033
1034\permanent\protected\def\dosetstrut
1035 {\enforced\let\strut\normalstrut
1036 \struthtdp\dimexpr\strutht\strutdp\relax
1037 \ifabsnum\dimexpr\struthtdp\lineheight\relax<\plustwo
1038
1039
1040
1041
1042 \strutdp\dimexpr\lineheight\strutht\relax
1043 \struthtdp\lineheight
1044 \fi
1045 \strutheight\strutht
1046 \strutdepth \strutdp
1047 \struttotal \struthtdp}
1048
1049\newconstant\c_strut_visual_mode
1050
1051
1052
1053
1054
1055\permanent\protected\def\strut
1056 {\relax
1057 \dontleavehmode
1058 \normalsrule
1059 \s!height\strutht
1060 \s!depth \strutdp
1061 \relax}
1062
1063\aliased\let\normalstrut\strut
1064
1065\permanent\protected\def\halfstrut
1066 {\relax
1067 \dontleavehmode
1068 \normalsrule
1069 \s!height.5\strutht
1070 \s!depth .5\strutdp
1071 \relax}
1072
1073\permanent\protected\def\quarterstrut
1074 {\relax
1075 \dontleavehmode
1076 \normalsrule
1077 \s!height.25\strutht
1078 \s!depth .25\strutdp
1079 \relax}
1080
1081\permanent\protected\def\depthstrut
1082 {\relax
1083 \dontleavehmode
1084 \normalsrule
1085 \s!height\dimexpr\strutht\struthtdp\plustwo\relax
1086 \s!depth \strutdp
1087 \relax}
1088
1089\permanent\protected\def\halflinestrut
1090 {\relax
1091 \dontleavehmode
1092 \normalsrule
1093 \s!height\dimexpr\strutht.5\struthtdp\relax
1094 \s!depth \strutdp
1095 \relax}
1096
1097\permanent\protected\def\noheightstrut
1098 {\relax
1099 \dontleavehmode
1100 \normalsrule
1101 \s!height\zeropoint
1102 \s!depth \strutdp
1103 \relax}
1104
1105\permanent\protected\def\nodepthstrut
1106 {\relax
1107 \dontleavehmode
1108 \normalsrule
1109 \s!height\strutht
1110 \s!depth \zeropoint
1111 \relax}
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125\installcorenamespace{struts}
1126
1127\permanent\tolerant\protected\def\setupstrut[#1]
1128 {\edef\m_strut{#1}
1129 \ifcsname\??struts\m_strut\endcsname
1130 \lastnamedcs
1131 \else
1132 \setcharstrut\m_strut
1133 \fi}
1134
1135\permanent\protected\def\synchronizestrut#1
1136 {\edef\m_strut{#1}
1137 \ifcsname\??struts\m_strut\endcsname
1138 \lastnamedcs
1139 \else
1140 \setcharstrut\m_strut
1141 \fi}
1142
1143\permanent\protected\def\dosynchronizestrut#1
1144 {\ifcsname\??struts#1\endcsname
1145 \lastnamedcs
1146 \else
1147 \setcharstrut{#1}
1148 \fi}
1149
1150\permanent\protected\def\showstruts
1151 {\showmakeup[strut]
1152 \settestcrlf}
1153
1154\aliased\let\showcolorstruts\showstruts
1155
1156\mutable\def\autostrutfactor{1.1}
1157
1158\permanent\protected\def\setautostrut
1159 {\begingroup
1160 \setbox\scratchbox\copy\b_strut_box
1161 \setstrut
1162 \ifdim\strutht>\autostrutfactor\ht\scratchbox
1163 \endgroup \setstrut
1164 \orelse\ifdim\strutdp>\autostrutfactor\dp\scratchbox
1165 \endgroup \setstrut
1166 \else
1167 \endgroup
1168 \fi}
1169
1170\newbox\nostrutbox \setbox\nostrutbox\emptyhbox
1171
1172\newtoks\everysetnostrut
1173
1174\permanent\protected\def\setnostrut
1175 {\expandtoks\everysetnostrut}
1176
1177\appendtoks
1178
1179 \enforced\lettonothing\strut
1180 \enforced\lettonothing\endstrut
1181 \enforced\lettonothing\begstrut
1182\to \everysetnostrut
1183
1184
1185
1186
1187\permanent\protected\def\leftboundary {\protrusionboundary\plusone}
1188\permanent\protected\def\rightboundary {\protrusionboundary\plustwo}
1189\permanent\protected\def\signalcharacter{\boundary\plusone\char\zerocount\boundary\plustwo}
1190
1191
1192
1193
1194
1195
1196
1197
1198\permanent\protected\def\begstrut
1199 {\ifmmode
1200 \strut
1201 \else
1202 \dontleavehmode
1203 \ifcase\struthtdp\else
1204 \spac_struts_beg
1205 \fi
1206 \fi
1207 \ignorespaces}
1208
1209\def\spac_struts_beg
1210 {\boundary\plusone
1211 \strut
1212
1213 \penalty\plustenthousand
1214
1215 \hskip\zeroskip}
1216
1217\permanent\protected\def\endstrut
1218 {
1219
1220 \relax\ifhmode
1221
1222 \spac_helpers_remove_unwantedspace
1223 \ifcase\struthtdp\else
1224 \spac_struts_end
1225 \fi
1226 \orelse\ifmmode
1227
1228 \spac_helpers_remove_unwantedspace
1229 \strut
1230 \fi}
1231
1232\def\spac_struts_end
1233 {\penalty\plustenthousand
1234
1235 \hskip\zeroskip
1236
1237 \strut
1238 \boundary\plustwo}
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256\permanent\protected\def\pseudostrut
1257 {\noindent}
1258
1259\aliased\let\pseudobegstrut\pseudostrut
1260\aliased\let\pseudoendstrut\removeunwantedspaces
1261
1262\permanent\protected\def\resetteststrut
1263 {\strutwidth\zeropoint
1264 \setstrut}
1265
1266\ifdefined\setfontparameters \else
1267 \def\setfontparameters{\expandtoks\everybodyfont}
1268\fi
1269
1270
1271
1272\letcsname\??struts\v!yes \endcsname\setstrut
1273\letcsname\??struts\v!auto \endcsname\setautostrut
1274\letcsname\??struts\v!no \endcsname\setnostrut
1275\letcsname\??struts\v!cap \endcsname\setcapstrut
1276\letcsname\??struts\v!fit \endcsname\setfontstrut
1277\letcsname\??struts\v!line \endcsname\setstrut
1278\letcsname\??struts\s!default\endcsname\setstrut
1279\letcsname\??struts\empty \endcsname\setstrut
1280
1281
1282
1283\permanent\def\baselinedistance{\the\lineheight}
1284
1285
1286
1287
1288
1289\pushoverloadmode
1290
1291\overloaded\permanent\protected\def\offinterlineskip
1292 {\baselineskip \ignoredepthcriterion
1293 \lineskip \zeroskip
1294 \lineskiplimit\maxdimen
1295
1296 \let\minimumlinedistance\zeropoint}
1297
1298\overloaded\permanent\protected\def\nointerlineskip
1299 {\prevdepth\ignoredepthcriterion}
1300
1301\aliased\let\normaloffinterlineskip\offinterlineskip
1302
1303\popoverloadmode
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315\ifdefined\getnofpreviouslines
1316
1317\else
1318 \let\getnofpreviouslines\!!zerocount
1319\fi
1320
1321\protected\def\page_otr_synchronize_page_yes
1322 {\aftergroup\page_otr_synchronize_page_indeed
1323 \global\enforced\let\page_otr_synchronize_page\relax}
1324
1325
1326
1327\protected\def\page_otr_synchronize_page_indeed
1328 {\ifx\currentoutputroutine\s!multicolumn\else\clf_synchronizepage\fi
1329 \global\enforced\let\page_otr_synchronize_page\page_otr_synchronize_page_yes}
1330
1331\let\page_otr_synchronize_page\page_otr_synchronize_page_yes
1332
1333\appendtoks
1334 \page_otr_synchronize_page
1335\to \everyaftershipout
1336
1337
1338
1339\protected\def\spac_helpers_push_interlineskip_yes
1340 {\enforced\edef\oninterlineskip
1341 {\baselineskip \the\baselineskip
1342 \lineskip \the\lineskip
1343 \lineskiplimit\the\lineskiplimit
1344 \noexpand\edef\noexpand\minimumlinedistance{\the\dimexpr\minimumlinedistance}
1345 \enforced\let\noexpand\offinterlineskip\noexpand\normaloffinterlineskip}}
1346
1347\protected\def\spac_helpers_push_interlineskip_nop
1348 {\enforced\let\oninterlineskip\setnormalbaselines}
1349
1350\pushoverloadmode
1351
1352\overloaded\permanent\protected\def\offinterlineskip
1353 {\ifdim\baselineskip>\zeropoint
1354 \spac_helpers_push_interlineskip_yes
1355 \else
1356 \spac_helpers_push_interlineskip_nop
1357 \fi
1358 \normaloffinterlineskip}
1359
1360\permanent\let\oninterlineskip\relax
1361
1362\popoverloadmode
1363
1364\permanent\protected\def\resetpenalties#1
1365 {\ifdefined#1
1366 \frozen#1\minusone
1367 \fi}
1368
1369\permanent\protected\def\setpenalties#1#2#3
1370 {\ifdefined#1
1371 \frozen#1\numexpr#2\plusone\relax\space\expandedrepeat\numexpr#2\relax{ #3}\zerocount\relax
1372 \fi}
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382\newinteger\c_spac_keep_lines_together
1383
1384\permanent\protected\lettonothing\restoreinterlinepenalty
1385
1386\protected\def\spac_penalties_restore
1387 {\enforced\protected\glettonothing\restoreinterlinepenalty
1388 \overloaded\global\resetpenalties\interlinepenalties
1389 \global\c_spac_keep_lines_together\zerocount}
1390
1391\permanent\protected\def\keeplinestogether#1
1392 {\ifnum#1>\c_spac_keep_lines_together
1393 \global\c_spac_keep_lines_together#1
1394 \overloaded\global\setpenalties\interlinepenalties\c_spac_keep_lines_together\plustenthousand
1395 \global\enforced\let\restoreinterlinepenalty\spac_penalties_restore
1396 \fi}
1397
1398
1399
1400
1401\immutable\integerdef\defaultdisplaywidowpenalty 50
1402\immutable\integerdef\defaultwidowpenalty 2000
1403\immutable\integerdef\defaultclubpenalty 2000
1404\immutable\integerdef\defaultbrokenpenalty 100
1405
1406\immutable\integerdef\defaultgriddisplaywidowpenalty \zerocount
1407\immutable\integerdef\defaultgridwidowpenalty \zerocount
1408\immutable\integerdef\defaultgridclubpenalty \zerocount
1409\immutable\integerdef\defaultgridbrokenpenalty \zerocount
1410
1411
1412
1413
1414\permanent\protected\def\nopenalties
1415 {\frozen\widowpenalty \zerocount
1416 \frozen\clubpenalty \zerocount
1417 \frozen\brokenpenalty\zerocount}
1418
1419\permanent\protected\def\setdefaultpenalties
1420 {\directsetup{\systemsetupsprefix\s!default}}
1421
1422\startsetups [\systemsetupsprefix\s!reset]
1423 \resetpenalties\widowpenalties
1424 \resetpenalties\clubpenalties
1425 \resetpenalties\interlinepenalties
1426\stopsetups
1427
1428
1429
1430\startsetups [\systemsetupsprefix\s!default]
1431
1432 \directsetup{\systemsetupsprefix\s!reset}
1433
1434 \frozen\widowpenalty \defaultwidowpenalty
1435 \frozen\clubpenalty \defaultclubpenalty
1436 \frozen\displaywidowpenalty \defaultdisplaywidowpenalty
1437 \frozen\brokenpenalty \defaultbrokenpenalty
1438
1439\stopsetups
1440
1441\startsetups [\v!grid] [\systemsetupsprefix\s!default]
1442
1443 \directsetup{\systemsetupsprefix\s!reset}
1444
1445 \frozen\widowpenalty \defaultgridwidowpenalty
1446 \frozen\clubpenalty \defaultgridclubpenalty
1447 \frozen\displaywidowpenalty \defaultgriddisplaywidowpenalty
1448 \frozen\brokenpenalty \defaultgridbrokenpenalty
1449
1450\stopsetups
1451
1452
1453
1454\startsetups [\systemsetupsprefix\v!strict]
1455
1456 \directsetup{\systemsetupsprefix\s!reset}
1457
1458 \setpenalties \widowpenalties \plustwo \maxdimen
1459 \setpenalties \clubpenalties \plustwo \maxdimen
1460 \setpenalties \orphanpenalties \zerocount
1461 \frozen \brokenpenalty \maxdimen
1462
1463\stopsetups
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475\definesystemattribute[skipcategory] [public]
1476\definesystemattribute[skippenalty] [public]
1477\definesystemattribute[skiporder] [public]
1478\definesystemattribute[snapmethod] [public]
1479\definesystemattribute[snapvbox] [public]
1480
1481
1482
1483
1484\installcorenamespace{gridsnappers}
1485\installcorenamespace{gridsnapperattributes}
1486\installcorenamespace{gridsnappersets}
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496\permanent\def\snappedvboxattribute{\ifgridsnapping attr\snapvboxattribute\c_attr_snapmethod\fi}
1497\permanent\def\setlocalgridsnapping{\ifgridsnapping \c_attr_snapvbox \c_attr_snapmethod\fi}
1498
1499\def\spac_grids_set_local_snapping#1
1500 {\ifgridsnapping
1501 \ifempty{#1}\else
1502 \spac_grids_snap_value_set{#1}
1503 \c_attr_snapvbox\c_attr_snapmethod
1504 \fi
1505 \fi}
1506
1507\def\spac_grids_expand_snapper#1
1508 {\edef\m_spac_snapper
1509 {\ifempty\m_spac_snapper\else\m_spac_snapper,\fi
1510 \ifcsname\??gridsnappersets#1\endcsname\lastnamedcs\else#1\fi}}
1511
1512\permanent\protected\def\installsnapvalues#1#2
1513 {\lettonothing\m_spac_snapper
1514 \rawprocesscommacommand[#2]\spac_grids_expand_snapper
1515 \edef\p_spac_snapper{#1:\m_spac_snapper}
1516 \ifcsname\??gridsnapperattributes\p_spac_snapper\endcsname
1517 \scratchcounter\lastnamedcs
1518 \else
1519 \scratchcounter\clf_definesnapmethod{#1}{\m_spac_snapper}
1520 \edefcsname\??gridsnapperattributes\p_spac_snapper\endcsname{\the\scratchcounter}
1521 \fi
1522 \edefcsname\??gridsnappers#1\endcsname{\c_attr_snapmethod\the\scratchcounter\relax}
1523 \letcsname\??gridsnappersets#1\endcsname\m_spac_snapper}
1524
1525\permanent\def\theexpandedsnapperset#1{\begincsname\??gridsnappersets#1\endcsname}
1526
1527\permanent\protected\def\usegridparameter#1
1528 {\edef\m_spac_grid_asked{#1\c!grid}
1529 \ifempty\m_spac_grid_asked
1530 \c_attr_snapvbox\attributeunsetvalue
1531 \else
1532 \spac_grids_snap_value_set\m_spac_grid_asked
1533 \c_attr_snapvbox\c_attr_snapmethod
1534 \fi}
1535
1536\permanent\tolerant\protected\def\definegridsnapping[#1]#*[#2]
1537 {\installsnapvalues{#1}{#2}}
1538
1539\edef\spac_grids_snap_value_reset
1540 {
1541 \c_attr_snapmethod\attributeunsetvalue}
1542
1543\def\spac_grids_snap_value_set#1
1544 {
1545 \begincsname\??gridsnappers#1\endcsname}
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558\def\spac_grids_snap_value_auto#1
1559 {\ifcsname\??gridsnappers#1\endcsname
1560 \lastnamedcs
1561 \else
1562 \installsnapvalues\s!dummy{#1}
1563 \csname\??gridsnappers\s!dummy\endcsname
1564 \fi}
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590\definegridsnapping[\v!normal] [\v!maxheight,\v!maxdepth,\v!strut]
1591\definegridsnapping[\v!standard] [\v!maxheight,\v!maxdepth,\v!strut]
1592\definegridsnapping[\v!yes] [\v!maxheight,\v!maxdepth,\v!strut]
1593
1594\definegridsnapping[\v!strict] [\v!maxdepth:0.8,\v!maxheight:0.8,\v!strut]
1595\definegridsnapping[\v!tolerant] [\v!maxdepth:1.2,\v!maxheight:1.2,\v!strut]
1596\definegridsnapping[\v!verytolerant] [\v!maxdepth:1.4,\v!maxheight:1.4,\v!strut]
1597
1598\definegridsnapping[\v!tolerant:10] [\v!maxdepth:1.1,\v!maxheight:1.1,\v!strut]
1599\definegridsnapping[\v!tolerant:20] [\v!maxdepth:1.2,\v!maxheight:1.2,\v!strut]
1600\definegridsnapping[\v!tolerant:30] [\v!maxdepth:1.3,\v!maxheight:1.3,\v!strut]
1601\definegridsnapping[\v!tolerant:40] [\v!maxdepth:1.4,\v!maxheight:1.4,\v!strut]
1602
1603\definegridsnapping[\v!top] [\v!minheight,\v!maxdepth,\v!strut]
1604\definegridsnapping[\v!bottom] [\v!maxheight,\v!mindepth,\v!strut]
1605\definegridsnapping[\v!both] [\v!minheight,\v!mindepth,\v!strut]
1606
1607\definegridsnapping[\v!broad] [\v!maxheight,\v!maxdepth,\v!strut,0.8]
1608\definegridsnapping[\v!fit] [\v!maxheight,\v!maxdepth,\v!strut,1.2]
1609
1610\definegridsnapping[\v!first] [\v!first]
1611\definegridsnapping[\v!last] [\v!last]
1612\definegridsnapping[\v!high] [\v!minheight,\v!maxdepth,\v!none]
1613\definegridsnapping[\v!one] [\v!minheight,\v!mindepth]
1614\definegridsnapping[\v!low] [\v!maxheight,\v!mindepth,\v!none]
1615\definegridsnapping[\v!none] [\v!none]
1616\definegridsnapping[\v!line] [\v!line]
1617\definegridsnapping[\v!strut] [\v!strut]
1618\definegridsnapping[\v!box] [\v!box]
1619\definegridsnapping[\v!min] [\v!min]
1620\definegridsnapping[\v!max] [\v!max]
1621
1622\definegridsnapping[\v!middle] [\v!maxheight,\v!maxdepth]
1623
1624\definegridsnapping[\v!math] [\v!maxdepth:1.05,\v!maxheight:1.05,\v!strut]
1625\definegridsnapping[\v!math:\v!line] [\v!math,\v!line,\v!split]
1626\definegridsnapping[\v!math:\v!halfline] [\v!math,\v!halfline,\v!split]
1627\definegridsnapping[\v!math:\v!line] [\v!math,\v!line,\v!split]
1628\definegridsnapping[\v!math:\v!halfline][\v!math,\v!halfline,\v!split]
1629
1630\permanent\protected\def\synchronizelocallinespecs
1631 {\bodyfontlineheight \normallineheight
1632 \bodyfontstrutheight\strutht
1633 \bodyfontstrutdepth \strutdp}
1634
1635\permanent\protected\def\synchronizegloballinespecs
1636 {\global\globalbodyfontlineheight \normallineheight
1637 \global\globalbodyfontstrutheight\strutht
1638 \global\globalbodyfontstrutdepth \strutdp}
1639
1640\appendtoks
1641 \synchronizegloballinespecs
1642 \synchronizelocallinespecs
1643\to \everysetupglobalinterlinespace
1644
1645\appendtoks
1646 \synchronizelocallinespecs
1647\to \everysetuplocalinterlinespace
1648
1649
1650
1651\def\restoreglobalinterlinespace
1652 {\mutable\let\normallineheight\globalbodyfontlineheight
1653 \bodyfontlineheight \globalbodyfontlineheight
1654 \bodyfontstrutheight\globalbodyfontstrutheight
1655 \bodyfontstrutdepth \globalbodyfontstrutdepth}
1656
1657
1658
1659
1660
1661
1662
1663\permanent\protected\def\synchronizeskipamounts
1664 {\bigskipamount
1665 \skipfactor\baselineskip
1666 \s!plus\skipgluefactor\baselineskip
1667 \s!minus\skipgluefactor\baselineskip
1668 \relax
1669 \medskipamount \bigskipamount \divideby\medskipamount \plustwo
1670 \smallskipamount\bigskipamount \divideby\smallskipamount\plusfour}
1671
1672
1673
1674
1675
1676\permanent\tolerant\protected\def\startgridsnapping[#1]
1677 {\snaptogrid[#1]\vbox\bgroup}
1678
1679\permanent\protected\def\stopgridsnapping
1680 {\egroup}
1681
1682\permanent\tolerant\protected\def\placeongrid[#1]
1683 {\snaptogrid[#1]\vbox}
1684
1685\permanent\tolerant\protected\def\snaptogrid[#1]
1686 {\ifgridsnapping
1687 \expandafter\spac_grids_snap_to_indeed
1688 \else
1689 \expandafter\gobbleoneargument
1690 \fi{#1}}
1691
1692\def\spac_grids_snap_to_indeed#1
1693 {\bgroup
1694 \spac_grids_snap_value_reset
1695 \dowithnextbox{\spac_grids_snap_to_finish{#1}}}
1696
1697
1698
1699\def\spac_grids_snap_to_finish#1
1700 {\ifvbox\nextbox
1701 \clf_vspacingcollapse\nextbox\relax
1702 \fi
1703 \ifempty{#1}
1704 \spac_grids_snap_value_set\v!normal
1705 \else
1706 \spac_grids_snap_value_set{#1}
1707 \fi
1708 \clf_vspacingsnap\nextbox\c_attr_snapmethod\relax
1709 \ifvbox\nextbox\vbox\else\hbox\fi attr \snapmethodattribute \zerocount {\box\nextbox}
1710 \egroup}
1711
1712\def\spac_grids_check_nop
1713 {\gridsnappingfalse
1714 \resetsystemmode\v!grid
1715 \spac_grids_snap_value_reset}
1716
1717\def\spac_grids_check_yes
1718 {\gridsnappingtrue
1719 \setsystemmode\v!grid
1720 \spac_grids_snap_value_set\p_grid}
1721
1722\permanent\protected\def\synchronizegridsnapping
1723 {\edef\p_grid{\layoutparameter\c!grid}
1724 \ifx\p_grid\v!no
1725 \spac_grids_check_nop
1726 \orelse\ifx\p_grid\v!off
1727 \spac_grids_check_nop
1728 \orelse\ifempty\p_grid
1729 \spac_grids_check_nop
1730 \else
1731 \spac_grids_check_yes
1732 \fi}
1733
1734\permanent\protected\def\setupgridsnapping[#1]
1735 {\setlayoutparameter\c!grid{#1}\synchronizegridsnapping}
1736
1737\mutable\lettonothing\checkedgridmethod
1738
1739\mutable\let\checkedgridscope\v!local
1740
1741\permanent\protected\def\checkgridmethod#1
1742 {\edef\p_grid{#1}
1743 \ifempty\p_grid
1744 \lettonothing\checkedgridmethod
1745 \let\checkedgridscope\v!local
1746 \else
1747 \splitatcolon\p_grid\checkedgridscope\checkedgridmethod
1748 \ifempty\checkedgridmethod
1749 \ifx\checkedgridscope\v!local\orelse\ifx\checkedgridscope\v!global\else
1750 \let\checkedgridmethod\checkedgridscope
1751 \let\checkedgridscope \v!local
1752 \fi
1753 \fi
1754 \fi}
1755
1756\permanent\protected\def\applygridmethod#1#2#3
1757 {\checkgridmethod{#1}
1758 \ifx\checkedgridscope\v!global
1759 \ifempty\checkedgridmethod \else
1760
1761
1762
1763
1764
1765
1766 \spac_grids_snap_value_set\checkedgridmethod
1767 \fi
1768 \hbox{#3}
1769 \else
1770
1771
1772
1773 \hbox\bgroup
1774 \ifempty\checkedgridmethod\orelse\ifconditional\headisdisplay
1775 #2
1776 \fi
1777 \snaptogrid[\checkedgridmethod]\hbox{#3}
1778 \egroup
1779 \fi}
1780
1781\protected\gdef\page_layouts_calculate_overshoot
1782 {\ifgridsnapping\ifcase\layoutlines
1783 \getnoflines\textheight
1784 \textovershoot\dimexpr\noflines\globalbodyfontlineheight\textheight\relax
1785 \fi\fi}
1786
1787\protected\def\page_layouts_report_overshoot
1788 {\page_layouts_calculate_overshoot
1789 \ifdim\textovershoot>\zeropoint
1790 \writestatus\m!layouts{gridmode,\space
1791 noflines: \the\noflines,\space
1792 textheight: \the\textheight,\space
1793 textovershoot: \the\textovershoot\space
1794 (maybe set number of lines instead)
1795 }
1796 \fi
1797 \glet\page_layouts_report_overshoot\page_layouts_calculate_overshoot}
1798
1799\appendtoks
1800 \page_layouts_report_overshoot
1801\to \everybeforepagebody
1802
1803
1804
1805\definepalet
1806 [grid]
1807 [ one=red,
1808 two=green,
1809 three=blue,
1810 four=gray]
1811
1812\permanent\protected\def\setgridtracebox#1[#2]
1813 {\setbox\nextbox#1
1814 {\hbox
1815 {\hbox to \zeropoint
1816 {\setlayoutcomponentattribute{\v!grid:\v!test}
1817 \color[grid:#2]{\ruledhbox \layoutcomponentboxattribute {\fakebox\nextbox}}
1818 \hss}
1819 \flushnextbox}}}
1820
1821\setnewconstant\gridboxlinenomode\plusone
1822\setnewconstant\gridboxlinemode \plusone
1823
1824\permanent\protected\def\gridboxvbox
1825 {\ifcase\gridboxlinemode
1826 \vpack
1827 \or
1828 \ruledvpack
1829 \or
1830 \vpack
1831 \or
1832 \ruledvpack
1833 \else
1834 \ruledvpack
1835 \fi}
1836
1837\permanent\def\gridboxwidth{\ifcase\gridboxlinemode0\or.5\or.5\or0\else.5\fi\linewidth}
1838
1839\permanent\protected\def\setgridbox#1#2#3
1840 {\setbox#1\gridboxvbox to #3
1841 {\forgetall
1842 \resetvisualizers
1843 \resetteststrut
1844 \offinterlineskip
1845 \hsize#2
1846 \ifcase\gridboxlinenomode\or\or\or
1847 \gridboxlinenomode\doifoddpageelse\plusone\plustwo
1848 \or
1849 \gridboxlinenomode\doifoddpageelse\plustwo\plusone
1850 \fi
1851 \topskipcorrection
1852 \gridboxvbox
1853 {\getrawnoflines{#3}
1854 \scratchdimen\dimexpr#2\lineheight\relax
1855 \localcontrolledrepeat\noflines
1856 {\strut
1857 \hskip.5\lineheight\relax
1858 \ifcase\gridboxlinenomode\or
1859 \rlap
1860 {\kern\dimexpr.2\bodyfontsize\scratchdimen\relax
1861 \infofont\hbox to \emwidth{\hss\the\currentloopiterator}}
1862 \or
1863 \llap
1864 {\infofont\hbox to \emwidth{\hss\the\currentloopiterator}
1865 \kern.2\bodyfontsize}
1866 \fi
1867 \vrule
1868 \s!height \gridboxwidth
1869 \s!depth \gridboxwidth
1870 \s!width \scratchdimen
1871 \par}}
1872 \vfill}}
1873
1874
1875
1876
1877
1878
1879
1880
1881\protected\def\spac_helpers_assign_skip#1#2
1882 {\ifcstok{#2}\v!line
1883 #1\ifgridsnapping
1884 \bodyfontlineheight
1885 \else
1886 \openlineheight
1887 \fi
1888 \else
1889 \ifgridsnapping
1890 \assigndimension{#2}{#1}{.25\bodyfontlineheight}{.5\bodyfontlineheight}\bodyfontlineheight
1891 \else
1892 \assigndimension{#2}{#1}\smallskipamount\medskipamount\bigskipamount
1893 \fi
1894 \fi
1895 \relax}
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924\installcorenamespace{vspacing}
1925\installcorenamespace{vspacingamount}
1926
1927\permanent\tolerant\protected\def\definevspacingamount[#1]#*[#2]#*[#3]
1928 {\ifarguments
1929
1930 \or
1931 \defcsname\??vspacingamount#1\endcsname{\lineheight}
1932 \or
1933 \defcsname\??vspacingamount#1\endcsname{\ifgridsnapping\lineheight\else#2\fi}
1934 \or
1935 \defcsname\??vspacingamount#1\endcsname{\ifgridsnapping#3\else#2\fi}
1936 \fi
1937 \clf_vspacingsetamount{#1}}
1938
1939\def\spac_vspacing_no_topskip
1940 {\c_attr_skipcategory\pluseleven}
1941
1942
1943\permanent\def\vspacingpredefinedvalue#1{\s_spac_vspacing_predefined\glueexpr\csname\??vspacingamount#1\endcsname\relax}
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958\permanent\tolerant\protected\def\definevspacing[#1]#*[#2]
1959 {\clf_vspacingdefine{#1}{#2}}
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993\permanent\tolerant\protected\def\vspacing[#1]
1994 {\ifarguments
1995 \spac_vspacing_yes[\currentvspacing]
1996 \else
1997 \spac_vspacing_yes[#1]
1998 \fi}
1999
2000\def\spac_vspacing_yes
2001 {\ifinpagebody
2002 \expandafter\spac_vspacing_yes_indeed
2003 \orelse\ifconditional\c_spac_packed_blank
2004 \expandafter\spac_vspacing_yes_indeed
2005 \else
2006 \expandafter\spac_vspacing_yes_ignore
2007 \fi}
2008
2009\def\spac_vspacing_nop
2010 {\ifinpagebody
2011 \expandafter\spac_vspacing_nop_indeed
2012 \orelse\ifconditional\c_spac_packed_blank
2013 \expandafter\spac_vspacing_nop_indeed
2014 \else
2015 \expandafter\spac_vspacing_nop_ignore
2016 \fi}
2017
2018\def\spac_vspacing_yes_indeed[#1]{\ifmmode\else\par\ifvmode\clf_injectvspacing\ifgridsnapping\plusone\else\zerocount\fi{#1}\fi\fi}
2019\def\spac_vspacing_nop_indeed {\ifmmode\else\par\ifvmode\clf_injectvspacing\ifgridsnapping\plusone\else\zerocount\fi{\currentvspacing}\fi\fi}
2020
2021\def\spac_vspacing_yes_ignore[#1]{\ifmmode\else\par\fi}
2022\def\spac_vspacing_nop_ignore {\ifmmode\else\par\fi}
2023
2024\permanent\protected\def\directvspacing#1
2025 {\ifmmode\else\par\ifvmode\clf_injectvspacing\ifgridsnapping\plusone\else\zerocount\fi{\ifempty{#1}\currentvspacing\else#1\fi}\fi\fi}
2026
2027\permanent\protected\def\directdefaultvspacing
2028 {\ifinpagebody
2029 \directvspacing\currentvspacing
2030 \orelse\ifconditional\c_spac_packed_blank
2031 \directvspacing\currentvspacing
2032 \fi}
2033
2034\permanent\protected\def\directcheckedvspacing
2035 {\ifinpagebody
2036 \expandafter\directvspacing
2037 \orelse\ifconditional\c_spac_packed_blank
2038 \expandafter\directvspacing
2039 \else
2040 \expandafter\gobbleoneargument
2041 \fi}
2042
2043\permanent\protected\def\useblankparameter#1
2044 {\edef\m_spac_blank_asked{#1\c!blank}
2045 \ifempty\m_spac_blank_asked\else
2046 \directvspacing\m_spac_blank_asked
2047 \fi}
2048
2049
2050
2051\permanent\protected\def\directvpenalty#1{\ifmmode\else\par\ifvmode\clf_injectvpenalty#1\relax\fi\fi}
2052\permanent\protected\def\directvskip #1{\ifmmode\else\par\ifvmode\clf_injectvskip #1\relax\fi\fi}
2053
2054
2055
2056\mutable\let\currentvspacing\s!default
2057
2058\permanent\tolerant\protected\def\setupvspacing[#1]
2059 {\ifarguments\else
2060 \edef\currentvspacing{#1}
2061 \fi
2062 \synchronizevspacing}
2063
2064\permanent\protected\def\synchronizevspacing
2065 {\ifempty\currentvspacing
2066 \let\currentvspacing\s!default
2067 \fi
2068 \spac_whitespace_setup_nop}
2069
2070\permanent\protected\def\restorestandardblank
2071 {\let\currentvspacing\v!standard}
2072
2073
2074
2075\definevspacingamount[\v!none] [\zeroskip] [\zeroskip]
2076\definevspacingamount[\v!big] [\bigskipamount] [\bodyfontlineheight]
2077\definevspacingamount[\v!medium] [\medskipamount] [.5\bodyfontlineheight]
2078\definevspacingamount[\v!small] [\smallskipamount] [.25\bodyfontlineheight]
2079\definevspacingamount[\v!line] [\openlineheight] [\bodyfontlineheight]
2080\definevspacingamount[\v!halfline] [.5\openlineheight] [.5\bodyfontlineheight]
2081\definevspacingamount[\v!quarterline] [.25\openlineheight] [.25\bodyfontlineheight]
2082\definevspacingamount[\v!formula] [\medskipamount] [.5\bodyfontlineheight]
2083\definevspacingamount[\v!white] [\parskip] [\bodyfontwhitespace]
2084\definevspacingamount[\v!height] [\strutht] [\bodyfontstrutheight]
2085\definevspacingamount[\v!depth] [\strutdp] [\bodyfontstrutdepth]
2086
2087\definevspacingamount[\v!standard] [.75\openlineheight] [.75\openlineheight]
2088
2089\permanent\def\bodyfontwhitespace
2090 {\dimexpr
2091 \ifzeropt\parskip
2092 \zeropoint
2093 \orelse\ifgridsnapping
2094 \bodyfontlineheight
2095 \else
2096 \parskip
2097 \fi
2098 \relax}
2099
2100
2101
2102\def\spac_overlay_lines
2103 {\directcheckedvspacing{\v!back,\v!overlay}
2104 \nointerlineskip}
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124\definevspacing[\v!preference][penalty:500]
2125\definevspacing[\v!samepage] [penalty:10000]
2126
2127\definevspacing[\v!always] [category:0]
2128\definevspacing[\v!max] [category:1]
2129\definevspacing[\v!force] [category:2]
2130\definevspacing[\v!disable] [category:5]
2131\definevspacing[\v!nowhite] [category:6]
2132\definevspacing[\v!back] [category:7]
2133\definevspacing[\v!packed] [category:8]
2134\definevspacing[\v!overlay] [category:9]
2135\definevspacing[\v!enable] [category:10]
2136
2137
2138
2139
2140\definevspacing[\v!weak] [order:0]
2141\definevspacing[\v!strong] [order:100]
2142
2143\definevspacing[\s!default] [\v!white]
2144
2145\newinteger\c_spac_vspacing_special_base \c_spac_vspacing_special_base = 32250
2146\newinteger\c_spac_vspacing_special_step \c_spac_vspacing_special_step = 10
2147\newinteger\c_spac_vspacing_special_done
2148
2149
2150
2151\protected\def\spac_vspacing_define_same_step#1#2
2152 {\begingroup
2153 \scratchcounterone\numexpr\plusthree*#1#2\relax
2154 \scratchcountertwo\numexpr\c_spac_vspacing_special_base\c_spac_vspacing_special_step*\scratchcounterone\relax
2155
2156 \normalexpanded{\definevspacing[\v!samepage\number#1\number#2][penalty:\the\scratchcountertwo]}
2157 \endgroup}
2158
2159
2160
2161
2162
2163
2164
2165
2166\protected\def\spac_vspacing_define_same_page#1
2167 {\localcontrolledloop\c_spac_vspacing_special_done=#1=\plusone
2168 {\spac_vspacing_define_same_step\currentloopiterator\zerocount
2169 \spac_vspacing_define_same_step\currentloopiterator\plusone
2170 \spac_vspacing_define_same_step\currentloopiterator\plustwo}
2171 \global\c_spac_vspacing_special_done#1\relax}
2172
2173\spac_vspacing_define_same_page{12}
2174
2175\def\spac_vspacing_same_page#1#2
2176 {\ifnum#1>\c_spac_vspacing_special_done
2177 \spac_vspacing_define_same_page{#1}
2178 \fi
2179
2180 \vspacing[\v!samepage\number#1\number#2]}
2181
2182\definevspacing[\v!default] [\v!big]
2183\definevspacing[\v!before] [\v!default]
2184\definevspacing[\v!inbetween][\v!default]
2185\definevspacing[\v!after] [\v!before]
2186
2187\setupvspacing
2188 [\v!big]
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200\permanent\protected\def\inhibitblank{\ifmmode\else\par\ifvmode\clf_injectdisable\fi\fi}
2201
2202\aliased\let\doinhibitblank\inhibitblank
2203
2204
2205
2206
2207
2208
2209\aliased\let\defineblank \definevspacing
2210\aliased\let\setupblank \setupvspacing
2211\aliased\let\blank \vspacing
2212\aliased\let\synchronizeblank \synchronizevspacing
2213\aliased\let\defineblankmethod\definevspacingamount
2214
2215
2216
2217
2218\installcorenamespace{vspace}
2219
2220\permanent\tolerant\protected\def\definevspace[#1]#*[#2]#*[#3]
2221 {\ifarguments
2222 \or
2223 \letcsname\??vspace:#1\endcsname\empty
2224 \or
2225 \defcsname\??vspace:#1\endcsname{#2}
2226 \or
2227 \defcsname\??vspace#1:#2\endcsname{#3}
2228 \fi}
2229
2230\letcsname\??vspace:\s!unknown\endcsname\zeropoint
2231
2232\def\spac_vspace_unknown
2233 {\csname\??vspace:\s!unknown\endcsname}
2234
2235\permanent\tolerant\protected\def\vspace[#1]#*[#2]
2236 {\par
2237 \ifvmode
2238 \removelastskip
2239 \vskip
2240 \ifparameter#2\or
2241 \ifcsname\??vspace#1:#2\endcsname
2242 \lastnamedcs
2243 \orelse\ifcsname\??vspace:#2\endcsname
2244 \lastnamedcs
2245 \else
2246 \spac_vspace_unknown
2247 \fi
2248 \orelse\ifparameter#1\or
2249 \ifcsname\??vspace:#1\endcsname
2250 \lastnamedcs
2251 \else
2252 \spac_vspace_unknown
2253 \fi
2254 \else
2255 \ifcsname\??vspace:\s!default\endcsname
2256 \lastnamedcs
2257 \else
2258 \spac_vspace_unknown
2259 \fi
2260 \fi
2261 \relax
2262 \fi}
2263
2264
2265
2266\installcorenamespace {hanging}
2267
2268\installdirectcommandhandler \??hanging {hanging}
2269
2270\setuphanging
2271 [\c!distance=.5\emwidth,
2272 \c!location=\v!left,
2273 \c!n=\zerocount]
2274
2275\lettonothing\m_spac_hanging_location
2276
2277\permanent\tolerant\protected\def\starthanging[#1]
2278 {\dontleavehmode\bgroup
2279 \ifhastok={#1}
2280 \lettonothing\m_spac_hanging_location
2281 \setupcurrenthanging[#1]
2282 \else
2283 \edef\m_spac_hanging_location{#1}
2284 \fi
2285 \ifempty\m_spac_hanging_location
2286 \edef\m_spac_hanging_location{\directhangingparameter\c!location}
2287 \fi
2288 \dowithnextboxcs\spac_hanging_finish\hbox}
2289
2290\permanent\protected\def\stophanging
2291 {\endgraf
2292 \egroup}
2293
2294\def\spac_hanging_finish
2295 {\scratchdistance\directhangingparameter\c!distance\relax
2296 \ifdim\ht\nextbox>\strutht
2297 \setbox\nextbox\tbox{\box\nextbox}
2298 \fi
2299 \scratchcounter\directhangingparameter\c!n\relax
2300 \ifnum\scratchcounter>\zerocount
2301 \frozen\hangafter\scratchcounter
2302 \else
2303 \getboxheight\scratchdimen\of\box\nextbox
2304 \getnoflines\scratchdimen
2305 \frozen\hangafter\noflines
2306 \fi
2307 \ht\nextbox\strutht
2308 \dp\nextbox\strutdp
2309 \scratchwidth\dimexpr\wd\nextbox\scratchdistance\relax
2310 \ifx\m_spac_hanging_location\v!right
2311 \frozen\hangindent\ifconditional\displaylefttoright\fi\scratchwidth
2312 \rlap{\kern\dimexpr\hsize\leftskip\wd\nextbox\relax\box\nextbox}
2313 \else
2314 \frozen\hangindent\ifconditional\displaylefttoright\else\fi\scratchwidth
2315 \llap{\box\nextbox\kern\scratchdistance}
2316 \fi
2317 \ignorespaces}
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341\installcorenamespace{fixedalternatives}
2342
2343\permanent\protected\lettonothing\stopfixed
2344
2345\permanent\protected\def\startfixed
2346 {\bgroup
2347 \ifhmode
2348 \expandafter\typo_fixed_start_h
2349 \else
2350 \expandafter\typo_fixed_start_v
2351 \fi}
2352
2353\tolerant\def\typo_fixed_start_h[#1]
2354 {\enforced\let\stopfixed\typo_fixed_stop_h
2355 \dowithnextbox{\typo_fixed_finish{#1}}
2356 \vbox\bgroup
2357
2358 \setlocalhsize}
2359
2360\protected\def\typo_fixed_stop_h
2361 {
2362 \egroup
2363 \egroup}
2364
2365\tolerant\def\typo_fixed_start_v[#1]
2366 {\enforced\let\stopfixed\typo_fixed_stop_v
2367 \startbaselinecorrection}
2368
2369\protected\def\typo_fixed_stop_v
2370 {\stopbaselinecorrection
2371 \egroup}
2372
2373\letcsname\??fixedalternatives \v!high\endcsname\bbox
2374\letcsname\??fixedalternatives \v!low\endcsname\tbox
2375\letcsname\??fixedalternatives \v!middle\endcsname\vcenter
2376\letcsname\??fixedalternatives \v!lohi\endcsname\vcenter
2377\letcsname\??fixedalternatives\s!unknown\endcsname\tbox
2378\letcsname\??fixedalternatives\s!default\endcsname\tbox
2379
2380\protected\def\typo_fixed_finish#1
2381 {\expandnamespacevalue\??fixedalternatives{#1}\s!default{\box\nextbox}}
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403\appendtoks
2404 \ifvmode\prevdepth\zeropoint\fi
2405\to \everystarttext
2406
2407\prevdepth\zeropoint
2408
2409
2410
2411\permanent\protected\def\checkedblank[#1]
2412 {\edef\p_blank{#1}
2413 \ifempty\p_blank
2414
2415 \orelse\ifx\p_blank\v!none
2416
2417 \else
2418 \blank[\p_blank]
2419 \fi}
2420
2421
2422
2423
2424
2425\newgluespec\prerolledblank
2426
2427\permanent\protected\def\prerollblank[#1]
2428 {\begingroup
2429 \edef\p_blank{#1}
2430 \ifempty\p_blank
2431 \global\prerolledblank\zeropoint
2432 \orelse\ifx\p_blank\v!none
2433 \global\prerolledblank\zeropoint
2434 \else
2435
2436 \scratchskip\plusten\lineheight
2437 \setbox\scratchbox\vbox
2438 {\vskip\scratchskip
2439 \kern\zeropoint
2440 \blank[\p_blank]}
2441
2442 \advanceby\scratchskip\ht\scratchbox
2443 \global\prerolledblank\scratchskip
2444 \fi
2445 \endgroup}
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463\permanent\protected\def\ignoreparskip{\c_spac_vspacing_ignore_parskip\plusone}
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484\permanent\tolerant\protected\def\blankbefore[#1]{\vadjust pre {\ifempty{#1}\blank\else\blank[#1]\fi}}
2485\permanent\tolerant\protected\def\blankafter [#1]{\vadjust post{\ifempty{#1}\blank\else\blank[#1]\fi}}
2486
2487
2488
2489\installcorenamespace{textdisplay}
2490
2491\installcommandhandler \??textdisplay {textdisplay} \??textdisplay
2492
2493\appendtoks
2494 \frozen\protected\edefcsname\e!start\currenttextdisplay\endcsname{\spac_textdisplay_start{\currenttextdisplay}}
2495 \frozen\protected\edefcsname\e!stop \currenttextdisplay\endcsname{\spac_textdisplay_stop}
2496\to \everydefinetextdisplay
2497
2498\setuptextdisplay
2499 [\c!factor=.5,
2500 \c!after=\textdisplayparameter\c!before]
2501
2502\tolerant\protected\def\spac_textdisplay_start#1#:[#S#2]
2503 {\par
2504 \begingroup
2505 \whitespace
2506 \forgetall
2507 \edef\currenttextdisplay{#1}
2508 \setupcurrenttextdisplay[#2]
2509 \textdisplayparameter\c!before
2510 \dpack
2511 \bgroup
2512 \strut
2513 \vskip\lineheight
2514 \vpack
2515 \s!yoffset \textdisplayparameter\c!factor\strutdp
2516 \bgroup}
2517
2518\protected\def\spac_textdisplay_stop
2519 {\egroup
2520 \vskip\lineheight
2521 \strut
2522 \egroup
2523 \textdisplayparameter\c!after
2524 \endgroup
2525 \par}
2526
2527\definetextdisplay[\v!textdisplay]
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552\protect \endinput
2553 |