# Can I assume that the \ht+\dp of a strutbox == \baselineskip?

In Context, as long as the interline space is set through the proper interface, it is safe to assume that (tex.box.strutbox.height + tex.box.strutbox.depth) == tex.baselineskip.width. This relation is important when copying the strutbox to add empty lines to some vlist.

However, I am working in Plain at the moment, where there is no such interface. Knuth in his examples sets the baseline skip independently of the strutbox, and what is more he uses absolute point values. Also, he defines multiple strutboxes with different height/depth ratios in gkpmac.tex and elsewhere. Yet, in manmac.tex (and Appendix E, p. 414f.) the bodyfont switches (\tenpoint, \ninepoint etc.) include appropriate strutboxes whose \ht + \dp equal the \baselineskip. Unfortunately I don’t have the experience that I could tell whether this is a convention amongst Plain users or just, well, Knuth.

So my questions: Is it reasonably safe to assume that whoever defines a font switch for Plain TeX will also take care of the strutbox? If I encounter a strutbox whose sum of height and depth does not match the local baselineskip, is it safe to recalculate these dimensions and overwrite the current strutbox? Is there some convention as to what is the correct height/depth ratio? Is it possibly part of the font metadata (OTF)? (Bonus points for good links: I can’t seem to google the topic without having my results cluttered with source files.)

For reference some code to recreate the strutbox in case its dimensions don’t match the baselineskip.

local strutbox = texbox.strutbox
local get_strut = function ()
local strutht, strutdp = strutbox.height, strutbox.depth
local struthtdp        = strutht + strutdp
local texbaselineskip  = tex.baselineskip.width
local newstrut         = node.copy_list(tex.box.strutbox)
strutht = (strutht / struthtdp) * texbaselineskip
strutdp = (strutdp / struthtdp) * texbaselineskip
newstrut.height, newstrut.list.height = strutht, strutht
newstrut.depth,  newstrut.list.depth  = strutdp, strutdp
return newstrut
end
local my_strut = get_strut()
print(string.format("strutbox ht %.4f, dp %.4f, htdp %.2f factor %.2f",
strutbox.height / 2^16,
strutbox.depth  / 2^16,
(strutbox.height + strutbox.depth) / 2^16,
(strutbox.height / strutbox.depth)))
print(string.format("my_strut ht %.4f, dp %.4f, htdp %.2f factor %.2f",
my_strut.height / 2^16,
my_strut.depth  / 2^16,
(my_strut.height + my_strut.depth) / 2^16,
(my_strut.height / my_strut.depth)))
print(strutbox)
print(strutbox.list.height/2^16)
tex.box.strutbox = my_strut


(Similar topic but afaics the specified ht/dp ratio doesn’t hold for plain http://tex.stackexchange.com/a/21834/14066)

-
many plain users will follow knuth's convention for the height and depth of a strut as in manmac. (this is true for ams-tex, for example.) but i wouldn't want to guarantee that the practice is universal. (note that \mathstrut is different -- it has only the height and depth of a parenthesis in the current font, and shouldn't be larger.) regarding font metadata in otf, my guess is that it depends on the whim of whoever designed the font. – barbara beeton Oct 10 '12 at 20:44
This is true for LaTeX, since every font size change command recomputes the strut box. With ofs.tex for Plain the strut is not taken into consideration; other font managers operate at even lower level. – egreg Oct 10 '12 at 20:53
@egreg I just hat a look at one of the font managers, plnfss. It provides a macro \setbaselineskip that also resets the strutbox according to the 7:3 height/depth proportion. – Philipp Gesang Oct 11 '12 at 10:03

many plain users will follow knuth's convention for the height and depth of a strut as in manmac.tex. there he defines three base sizes, each with its own value for \strutbox:

\def\tenpoint{\def\rm{\fam0\tenrm}%
<...>
\normalbaselineskip=12pt
<...>
\setbox\strutbox=\hbox{\vrule height8.5pt depth3.5pt width\z@}%
\normalbaselines\rm}

\def\ninepoint{\def\rm{\fam0\ninerm}%
<...>
\normalbaselineskip=11pt
<...>
\setbox\strutbox=\hbox{\vrule height8pt depth3pt width\z@}%
\normalbaselines\rm}

\def\eightpoint{\def\rm{\fam0\eightrm}%
<...>
\normalbaselineskip=9pt
<...>
\setbox\strutbox=\hbox{\vrule height7pt depth2pt width\z@}%
\normalbaselines\rm}


as one can see, the height + depth of the \strutbox does equal the \normalbaselineskip, with the height and depth greater than the cap height and descender depth relatively in proportion; not all the "excess" is above or below. (other plain formats follow this principle; ams-tex does, for example.) but i wouldn't want to guarantee that the practice is universal.

note that \mathstrut is different -- it is defined in plain.tex:

\def\mathstrut{\vphantom(}


so it has only the height and depth of a parenthesis in the current font, and shouldn't be larger. (this can be a trap with fonts not designed for use with math; tex fonts have vertically symmetrical parentheses, with equal extents above and below the math axis. fonts designed with only text setting in mind may not have a well defined math axis at all, so "your mileage may vary". check! then, if necessary, define the \mathstrut as a \vphantom of two characters, one having the maximum height found in the set comprising alphabet + numerals + punctuation, and the other having the maximum depth.)

as designer of numerous document-specific plain styles, including that of tugboat, i faithfully adhere to the manmac principle; it ensures uniformity without effort, so attention need be paid only to exceptional situations.

gkpmac.tex is an exceptional case. it was designed for one particular book, Concrete Mathematics, which did not have varying blocks of main text in different sizes. instead, it had well-controlled "inserts" (which for this discussion include headings and small marginal "graffiti") for which the type size and \baselineskip are set individually so that struts are unnecessary in these contexts. the height + depth of the \strutbox do equal the \baselineskip of 13pt for the main text. the rationale for these settings is given in knuth's tugboat article "Typesetting Concrete Mathematics".

regarding whether or not a designer of a plain tex style will follow knuth's lead in setting size-conforming \strutboxes, my recommendation is to check the code before making assumptions. my personal view is that if such \strutboxes are not provided, and i were obliged to use that style, i would rewrite the code to provide them.

regarding font metadata in otf, my guess is that it depends on the whim of whoever designed the font metrics. sorry, i can't provide links, but maybe @KhaledHosny (implementor of the xits fonts and others) can address this point.

-