ontarget-radicals.tex /size: 5585 b    last modification: 2024-01-16 10:21
1% language=us runpath=texruns:manuals/ontarget
2
3\startcomponent ontarget-radicals
4
5\environment ontarget-style
6
7\startchapter[title={Somewhat radical}]
8
9Here we will discuss an aspect of radicals, namely how variants get applied. Take
10the following situation:
11
12\startbuffer[one]
13\dontleavehmode \glyphscale 4000
14\ruledhbox{\setupmathradical[sqrt][mindepth=0pt,strut=no,leftmargin=0pt]$\sqrt{x+1}$ $\sqrt{x-1}$}\blank
15\ruledhbox{\setupmathradical[sqrt][mindepth=0pt,strut=no,leftmargin=0pt]$\sqrt{1+x}$ $\sqrt{1-x}$}
16\stopbuffer
17
18\startbuffer[two]
19\dontleavehmode \glyphscale 4000
20\ruledhbox{\setupmathradical[sqrt][mindepth=0pt,strut=no,leftmargin=0pt]$\sqrt{\frac{x+1}{x-1}}$}
21\ruledhbox{\setupmathradical[sqrt][mindepth=0pt,strut=no,leftmargin=0pt]$\sqrt{\frac{1+x}{1-x}}$}
22\stopbuffer
23
24\startbuffer[three]
25\dontleavehmode \glyphscale 4000
26\ruledhbox{$\sqrt{\frac{x+1}{x-1}}$}
27\ruledhbox{$\sqrt{\frac{1+x}{1-x}}$}
28\stopbuffer
29
30\startlinecorrection
31\switchtobodyfont[modern-nt]\getbuffer[one]
32\stoplinecorrection
33
34Watch the slight difference in radical heights. Now look at this:
35
36\startlinecorrection
37\switchtobodyfont[modern-nt]\getbuffer[two]
38\stoplinecorrection
39
40Here we need to make sure that we don't run into the slope, because, when we have
41a close look at the shapes we see that the radical symbol has a tight bounding
42box:
43
44\startlinecorrection
45\showglyphs\switchtobodyfont[modern-nt]\getbuffer[one]
46\stoplinecorrection
47
48In pagella we get:
49
50\startlinecorrection
51\showglyphs\switchtobodyfont[pagella-nt]\getbuffer[two]
52\stoplinecorrection
53
54and in antykwa:
55
56\startlinecorrection
57\showglyphs\switchtobodyfont[antykwa]\getbuffer[two]
58\stoplinecorrection
59
60But now look at this formula:
61
62\startlinecorrection
63\switchtobodyfont[antykwa]
64{\showglyphs \showstruts \getbuffer[three]}
65{\getbuffer[three]}
66\stoplinecorrection
67
68Here we see several mechanisms in action and for a good reason. First of all we
69want similar subformulas (under the symbol) to have compatible radicals. For this
70we use special struts so that we always have at least some height. We also
71compensate for slight differences in depth by setting a minimum depth. Finally we
72add a bit of margin. That last feature moves the content free from the symbols
73which means that we can have less distance between the top of the content and the
74rule. In many fonts that distance is set to a value that prevents clashes and the
75more slope we have, the more opportunity there is to clash.
76
77When the best fit decision is made for a radical, the effective height of the
78content (height plus depth of the box) is incremented by a gap variable. The
79standard specifies the \typ {RadicalVerticalGap} as \quotation {Space between the
80(ink) top of the expression and the bar over it. Suggested: 1.25 default rule
81thickness.} and \typ {RadicalDisplayStyleVerticalGap} as \quotation {Space
82between the (ink) top of the expression and the bar over it. Suggested: default
83rule thickness plus .25 times x-height.}. These values are actually rather font
84dependent because the slope needs to be taken into account; there is also a
85visual aspect to it.
86
87We can't tweak the radical width because the rule has to be attached. If we could
88we'd have to do it for every variant. So, instead we set up radical like this:
89
90\starttyping
91\setupmathradical
92  [strut=height,     % only height
93   leftmargin=.05mq, % fraction of math quad
94   mindepth=.05mx]   % fraction of math x height
95\stoptyping
96
97When deciding what size to use, a list of variants is followed till there is a
98match and when we run out of variants an extensible is constructed. Here is the
99list of possible sizes in the current font:
100
101\startbuffer[four]
102\startformula
103    \glyphscale 2000
104    \dorecurse {\nofmathvariants "221A} {
105        \ruledhbox{$\char \getmathvariant #1 "221A \relax$}
106        \quad
107    }
108\stopformula
109\stopbuffer
110
111\startbuffer[five]
112\startformula
113    \glyphscale 2000
114    \dorecurse {\nofmathvariants "221A} {
115        \setbox\scratchbox\ruledhbox{$\char \getmathvariant #1 "221A$}
116        \raise\dp\scratchbox\box\scratchbox
117        \quad
118    }
119\stopformula
120\stopbuffer
121
122\getbuffer[four]
123
124However, when we don't center around the math axis we get a more distinctive view
125on the steps:
126
127\getbuffer[five]
128
129It will be clear that the steps can't be too large but there are fonts out there
130that behave rather extreme, like Cambria:
131
132{\switchtobodyfont[cambria-nt] \getbuffer[five]}
133
134The only way out here is to either inject scaled variants into the list of
135possibilities or to simply ignore all except the first one and go straight to the
136extensible, so that's what we do, in combination with tweaked parameters and a
137margin:
138
139{\switchtobodyfont[cambria] \getbuffer[five]}
140
141As with many font parameters (also in text) one sometimes wonder if font designer
142test with real examples. There are of course exceptions, for instance the \typ
143{ebgaramond} font, but that one goes over the top in other areas. Here one can
144also wonder if the upper half of the range makes sense over an extensible. For
145consistency one wants steps to be not too small, so that a sequence of radicals
146looks simular, but steps larger than for instance the height are probably bad.
147
148\pushoverloadmode
149{\switchtobodyfont[ebgaramond] \let\quad\thinspace \getbuffer[five]}
150\popoverloadmode
151
152So, as with other examples that we give of tweaking math, it is clear that there
153is no way around also tweaking radicals, and we're not even talking of the way we
154fine tune the positioning of degrees in radicals because that is also a neglected
155area in \OPENTYPE\ math fonts.
156
157\stopchapter
158
159\stopcomponent
160
161