spac-pas.mkxl /size: 4529 b    last modification: 2025-02-21 11:03
1%D \module
2%D   [       file=spac-pas,
3%D        version=2023.06.10,
4%D          title=\CONTEXT\ Spacing Macros,
5%D       subtitle=Passes,
6%D         author=Hans Hagen & Mikael Sundqvist,
7%D           date=\currentdate,
8%D      copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
9%C
10%C This module is part of the \CONTEXT\ macro||package and is
11%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
12%C details.
13
14\writestatus{loading}{ConTeXt Spacing Macros / Passes}
15
16\registerctxluafile{spac-pas}{autosuffix}
17
18%D Here we set up some nano typography features. We have moved the penalties
19%D that deal with par building here. We also separated them from the page
20%D builder related ones.
21
22\unprotect
23
24% \resetpenalties\orphanpenalties
25
26%integerdef\unknownparpassclass     "000
27\integerdef\verylooseparpassclass   "001
28\integerdef\looseparpassclass       "002
29\integerdef\almostlooseparpassclass "004
30\integerdef\barelylooseparpassclass "008
31\integerdef\decentparpassclass      "010
32\integerdef\barelytightparpassclass "020
33\integerdef\almosttightparpassclass "040
34\integerdef\tightparpassclass       "080
35\integerdef\verytightparpassclass   "100
36
37%  \fitnessdemerits \numexpr \verylooseparpassclass + \almostlooseparpassclass \relax % 5 default
38
39% \integerdef\indecentparpassclasses\numexpr
40%       \verylooseparpassclass
41%     + \looseparpassclass
42%     + \almostlooseparpassclass
43%     + \barelylooseparpassclass
44%     % \decentparpassclass
45%     + \barelytightparpassclass
46%     + \almosttightparpassclass
47%     + \tightparpassclass
48%     + \verytightparpassclass
49% \relax
50
51\integerdef\allparpassclasses "FFFF
52
53\integerdef\indecentparpassclasses\numexpr
54    \allparpassclasses
55  - \decentparpassclass
56\relax
57
58\integerdef\almostdecentparpassclasses\numexpr
59      \verylooseparpassclass
60    + \looseparpassclass
61    + \almostlooseparpassclass
62    % \decentparpassclass
63    + \almosttightparpassclass
64    + \tightparpassclass
65    + \verytightparpassclass
66\relax
67
68\integerdef\looseparpassclasses\numexpr
69      \verylooseparpassclass
70    + \looseparpassclass
71    % \decentparpassclass
72    + \almostlooseparpassclass
73    + \barelylooseparpassclass
74\relax
75
76\integerdef\tightparpassclasses\numexpr
77      \verytightparpassclass
78    + \tightparpassclass
79    % \decentparpassclass
80    + \almosttightparpassclass
81    + \barelytightparpassclass
82\relax
83
84\appendtoks
85    \ifcase\linebreakpasses\else
86        \linebreakpasses\zerocount
87        % maybe always:
88        \pretolerance   \plushundred
89        \tolerance      \plustwohundred
90    \fi
91\to \everyforgetall
92
93\startsetups align:pass:none
94    \pretolerance   \plushundred
95    \tolerance      \plustwohundred
96    \parpasses      \zerocount
97    \linebreakpasses\zerocount
98  % \lettonothing\currentalignpass
99\stopsetups
100
101% see spac-pas-imp-tests.mkxl
102
103\lettonothing\currentalignpass
104
105\permanent\protected\def\setupalignpass[#1]%
106  {\cdef\tempstring{align:pass:#1}%
107   \ifx\tempstring\currentalignpass\else
108     \linebreakpasses\plusone % none will reset this
109     \let\currentalignpass\tempstring
110     \fastsetup\currentalignpass
111     \relax % to be sure
112   \fi}
113
114\appendtoks
115    \ifcase\linebreakpasses\else
116      \fastsetup\currentalignpass
117    \fi
118\to \everybodyfont
119
120%D This sort of belongs here:
121
122\permanent\protected\def\optionalword#1%
123  {\removeunwantedspaces\wordboundary\discretionary{}{}{#1}}
124
125%D \starttyping
126%D \dostepwiserecurse{80}{100}{1}{\hsize #1mm
127%D     Many readers will skim over formulas on their first reading
128%D     of your exposition. Therefore, your sentences should flow
129%D     smoothly when all but the simplest formulas are replaced by
130%D     \quotation {blah} or some other \optionalword {grunting }noise.
131%D     \page
132%D }
133%D \stoptyping
134
135% Musical timestamp: Archive's Call to Arms & Angels (and Super8) in loop mode
136% (June 2023, weirdly I had missed those releases in 2022).
137
138% \dorecurse{41}{line #1\par}
139% here \singlelinepenalty20000 \updateparagraphpenalties here here
140
141%D Todo:
142
143% \specificationdef \parpassonemoreline \parpasses 3
144%     looseness    1
145%     tolerance  100
146% next
147%     tolerance 200
148%     hyphenation  1
149% next
150%     demerits 1
151%     emergencystretch 4em
152%
153% \specificationdef \parpasstwomorelines \parpasses 3
154%     looseness    2
155%     tolerance  100
156% next
157%     tolerance  200
158%     hyphenation  1
159% next
160%     demerits 1
161%     emergencystretch 8em
162%
163% \permanent\protected\def\onemoreline {\parpassesexception\parpassonemoreline }
164% \permanent\protected\def\twomorelines{\parpassesexception\parpasstwomorelines}
165
166\protect
167