# determine current font height

There are many answers here which explain how to obtain the size of the current font (`\f@size`) and others which explain how to obtain the height of a given character (`\settoheight`) in the current font.

I would like to know how to obtain the height of a font, i.e. the distance between the upper edge of the enclosing box of a capital letter and the baseline. Is there such a metric defined for fonts, i.e. is there such a property within font design? – The idea is motivated by the graphic in this answer that the letters "Q" and "A" (at least in that font, at least to the precision of the rendering) have the same height.

If not, is there a "typical" capital letter whose height could be used as a substitute?

Background: I'm trying to align a TikZ text node with respect to its upper edge, but the actual text can vary depending on the circumstances and may or may not contain capital letters. The idea would be to position using the baseline instead, and set the coordinate lower by a certain amount.

• Could you give a MWE to show what effect do you want to achieve? Jul 15, 2020 at 4:12
• @ZhiyuanLck, I'm looking for a generic answer, not the solution to a concrete programming problem. I added the "Background" only for motivation. Jul 15, 2020 at 4:32

The way `fontspec` determines `Scale=MatchUppercase` is exactly how you said in your question. It measures the height of the letter `H`, which you can do with `\settoheight`. The H-height is a traditional way of doing it (I’ve also seen T), but some fonts might have an ornament on the letter H that makes a different letter a better choice.
If you want to measure the descent, you could take the depth of `gjpqy`. This will give you the greatest depth of any of them.
• Thanks, if `fontspec` does it this way, that's good enough for me. – For future reference for people who want to achieve something similar: I ended up using `node[anchor=base,yshift=-height("H")]`; `height` is TikZ' shorter version of `\settoheight`. Jul 15, 2020 at 4:34