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 https://tex.stackexchange.com/a/21834/14066)
manmac. (this is true for ams-tex, for example.) but i wouldn't want to guarantee that the practice is universal. (note that\mathstrutis 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:44ofs.texfor Plain the strut is not taken into consideration; other font managers operate at even lower level. – egreg Oct 10 '12 at 20:53\setbaselineskipthat also resets the strutbox according to the 7:3 height/depth proportion. – Philipp Gesang Oct 11 '12 at 10:03