ontarget-bars.tex /size: 7387 b    last modification: 2024-01-16 10:21
1% language=us runpath=texruns:manuals/ontarget
2
3\startcomponent ontarget-bars
4
5\usebodyfont[modern]
6\usebodyfont[modern-nt]
7
8\environment ontarget-style
9
10\startchapter[title={Between bars}]
11
12\startsubject[title=Inconsistencies]
13
14The bar in math can a real pain. There are several reasons for this, for instance
15there is no proper left, middle and right bar in \UNICODE\ and as a result there
16is more work involved in getting them spaced well. Another possible issue can be
17to make them fit well with other fences. You expect the bars in \im {\left(x
18\middle| y\right)} and \im {\left|x \middle| y\right|} to look similar.
19
20\start \glyphscale2000 \startformula
21    \mathaxisbelow \dorecurse {\nofmathvariants \barasciicode} {
22        \char \getmathvariant #1 \leftbracketasciicode
23        \char \getmathvariant #1 \barasciicode
24        \char \getmathvariant #1 \rightparentasciicode
25        \quad
26    }
27\stopformula \stop
28
29However, math fonts have their surprises:
30
31\start \switchtobodyfont[modern-nt] \glyphscale2000 \startformula
32    \mathaxisbelow \dorecurse {\nofmathvariants \barasciicode} {
33        \char \getmathvariant #1 \leftbracketasciicode
34        \char \getmathvariant #1 \barasciicode
35        \char \getmathvariant #1 \rightparentasciicode
36        \quad
37    }
38\stopformula \stop
39
40In Latin Modern only the first variant is tuned to work together but for larger
41sizes the bars stick out. This is a problem when we want fences to adapt. The
42fact that such side effects probably get unnoticed comes from the fact that macro
43packages assume \type {\bigg} and friends to be used but in \CONTEXT, and
44especially \LMTX, we have various mechanisms for this. One method is based on
45selecting specific variants, in the case of Latin Modern 1, 4, 6 and 7, where in
46in fact 7 is the last one before we switch to extensible fences. One can try to
47use a different selection for brackets and bars when there is no nice match but
48there are no equal height matches.
49
50\startbuffer
51\im {\left| x       \right|}
52\im {\left| x^2     \right|}
53\im {\left| x^{1/n} \right|}
54\stopbuffer
55
56\typebuffer
57
58These example formulas can trigger a larger fence:
59
60\startlinecorrection \showglyphs
61\ruledhbox{\scale[width=1tw]{\getbuffer}}
62\stoplinecorrection
63
64In untweaked Latin Modern we get this:
65
66\startlinecorrection \switchtobodyfont[modern-nt] \showglyphs
67\ruledhbox{\scale[width=1tw]{\getbuffer}}
68\stoplinecorrection
69
70The slash in this font is rather high and therefore triggers the larger fence.
71One can configure this with the \typ {\delimiterfactor} and \typ
72{\delimitershortfall} but as you can see values have to relate to the font. In
73\LMTX\ we set them to 1000 and 0pt and use the \LUAMETATEX\ equivalent font
74variables instead, so we can indeed fine tune per font.
75
76To come back to the mismatch in fences, this is dealt with in a tweak: we scale
77the single, double and triple bars to match the brackets:
78
79\start \switchtobodyfont[modern] \startformula
80    \mathaxisbelow \dorecurse {\nofmathvariants \barasciicode} {
81        \char \getmathvariant #1 \leftbracketasciicode
82        \char \getmathvariant #1 \barasciicode
83        \char \getmathvariant #1 \rightparentasciicode
84        \quad
85    }
86\stopformula \stop
87
88Combined with proper settings for the factor (or percentage in \OPENTYPE\ math
89speak) and shortfall, we now get:
90
91\startlinecorrection \switchtobodyfont[modern] \showglyphs
92\ruledhbox{\scale[width=1tw]{\getbuffer}}
93\stoplinecorrection
94
95When we let the upgraded math subsystem evolve we make many examples.
96Unfortunately there is always an exception. For instance, we test a specific
97font, notice something, deal with it, even test all fonts in inline and display
98math and then after months the exception shows up. In this case it was the \im
99{1/n} in a superscript that (only?) in Latin Modern goes over the top. Actually
100we had noticed that bars are often inconsistent so we had a \type {fixbars}
101tweak, However, for Latin Modern we found that the inconsistency between bars and
102other fences needed something more drastic. Of course fixing the font is best but
103we're beyond that stage now: the fonts are basically frozen.
104
105A close inspection of the too large fence which itself results from it being
106larger than expected by design (which we noticed by adding parentheses) itself
107was the result from deciding to configure additional inter|-|atom spacing for
108open and close fences (see below) which then brings us back to the fact that one
109bar serves three purposes. We might actually introduce these three (left, middle
110and right) at some point.
111
112\startbuffer
113\dm {\left| \frac{n^3 - 2n + 1}{n^5 - 3} - 0 \right| < \frac{4}{n^2} }
114\stopbuffer
115
116\startlinecorrection
117\switchtobodyfont[modern]
118\hbox{\scale[width=.45tw]{\getbuffer}\hskip .1tw
119\inherited\setmathspacing\mathordinarycode\mathclosecode\allmathstyles\zeromuskip
120\scale[width=.45tw]{\getbuffer}}
121\stoplinecorrection
122
123\stopsubject
124
125\startsubject[title=Missing shapes]
126
127The tweak discusses in the previous section is a brute force one: we put an
128extensible on the base glyph. Among the arguments for doing this is that we want
129to be able to add consistent double and triple bars. Without mentioning fonts
130explicitly (as some might get fixed after we files bug reports) this is what
131we observed:
132
133\startitemize[packed]
134\startitem
135    There are single bars, double bars and triple bars and each has variants and
136    extensibles. This is okay.
137\stopitem
138\startitem
139    Most are there but the triple bar has no variants and extensibles
140\stopitem
141\startitem
142    We have all three base characters but no variants. The extensible has a
143    different width.
144\stopitem
145\startitem
146    Single, double and triple bars are inconsistent with each other.
147\stopitem
148\startitem
149    Everything is there but widths differ per variant; some match the parenthesis,
150    brackets and braces but not consistently.
151\stopitem
152\startitem
153    The different variant sizes are out of sync with the sizes of parenthesis
154    etc.\ and this makes for inconsistent matches, especially when also the width
155    and positioning differs.
156\stopitem
157\startitem
158    Spacing between and around double and triple bars isn't always consistent.
159\stopitem
160\stopitemize
161
162These observations lead us to the conclusion that there is no single tweak that
163can fix this. Adapting the \quote {addbars} tweak to deal with all this made for
164too many alternatives in checks and fixes to feel comfortable with. This is why
165we decided to come up with companion fonts that provide the missing double and
166triple variants and extensibles consistent with the single ones, fix spacing in
167double and triple ones, fix inconsistent widths of bars, etc. Minor details like
168bad positioning are already handled well do we can keep the \quote {design} as it
169is.
170
171\usebodyfont[pagella]
172
173\start
174\switchtobodyfont[pagella,15pt]
175\dm{
176  \dorecurse {\nofmathvariants "28} {
177    \char \getmathvariant #1 "5B
178    \char \getmathvariant #1 "7B
179    \char \getmathvariant #1 "28
180    \char \getmathvariant #1 "7C
181    \char \getmathvariant #1 "29
182    \char \getmathvariant #1 "7D
183    \char \getmathvariant #1 "5D \quad }
184}
185
186\dm{
187  \dorecurse {\nofmathvariants "7C} {
188    \char \getmathvariant #1 "7C   \enspace
189    \char \getmathvariant #1 "2016 \enspace
190    \char \getmathvariant #1 "2980 \quad }
191}
192\stop
193
194\stopsubject
195
196\startsubject[title=Different sizes]
197
198middle
199
200\stopsubject
201
202\stopchapter
203
204\stopcomponent
205