I would like to scale graphical elements (like images, tikz
and tikz-timing
diagrams) relative to the font size, so that they have the same height as an normal uppercase letter (i.e. X
or M
; I noticed they have about the same height, but the tip of A
is slightly higher). I also sometimes like to do this with the normal letter depth (e.g. the depth of y
or g
).
I know that besides the possibility to use the ex
or em
units for font size relative length (1.6ex =~ height of X
), the current font size is stored inside \f@size
as string length with the pt
stripped. So for normal 10pt font it contains 10
. There is also \ht\strutbox
and \dp\strutbox
which are .7\baselineskip
and .3\baselineskip
, respectively, which in turn is about 1.2x the font size.
However, a \rule{1pt}{10pt}
is significant higher than a 10pt X
. This is not that surprising, because \ht\strutbox
(which is anyway supposed to by higher than X
) is 10pt x 1.2 x 0.7 = 8.4pt in size.
Question: How is the actual letter height and depth calculated if the font size is known? Is this always a constant factor? Is this font dependent?
I would like to avoid to have to box an X
and measure its size, but this would be plan B.
X
orM
seem to be good candidates for the height, but I'm not sure for the depth:y
org
maybe? I could just box the whole alphabet but this might lead to a worse result. Like I said, theA
is a little bit higher and taking the absolute maximum and minimum would most likely not look good.pplr8t
(Palatino), which gives 4.68994pt, while a lowercase x is 4.84497pt high. Withec-qplr
(TeX Gyre Pagella) the same measurements give 4.48999pt and 4.41998pt respectively. I'm with barbara: go with plan B. For the height a B can be a good choice (I wouldn't use M that suffers the same problem as A); for the depth maybe a q that hasn't fancy curves at the bottom.