# How to determine the partial heights of a font

I want to determine the heights of a font.

\f@size gives me the total height of the line. This should be top line to bottom line. How can I determine the length between top and 2 (fat) and the length between 3 and bottom? Because they needn't be to be the same. I tried \advance by -1ex and dividing by 2, but this doesn't work as intended (accurate).

In the calc packet the commands \heightof and \depthof can be used. For clarity I use lengths for all the distances, and in \Epheightdiff the difference in height between E and p is given.

\documentclass{article}
\usepackage{xcolor}
\usepackage{calc}
\newlength\Eheight
\newlength\pheight
\newlength\pdepth
\newlength\Epheightdiff
%%
\begin{document}
\setlength\Eheight{\heightof{E}}
\setlength\pheight{\heightof{p}}
\setlength\pdepth{\depthof{p}}
%%
\setlength\Epheightdiff{\Eheight-\pheight}

\noindent
\rlap{\textcolor{green}{\rule{3em}{0.2pt}}}%
\raisebox{\pheight}{\textcolor{yellow}{\rlap{\rule{3em}{\Epheightdiff}}}}%
\raisebox{\Eheight}{\textcolor{red}{\rlap{\rule{3em}{0.2pt}}}}%
\raisebox{\pheight}{\textcolor{blue}{\rlap{\rule{3em}{0.2pt}}}}%
\raisebox{-\pdepth}{\textcolor{cyan}{\rlap{\rule{3em}{0.2pt}}}}%
Ep

\end{document}


\f@size relates to the nominal font size as specified by the font designer, it doesn't relate to any length that may be measured within the font.

Assuming etex you can find the height and depth of any character (for example p) via

\fontcharht \font \p

\fontchardp \font \p


etc

• This would explain the aberrations in my example. – MaestroGlanz Nov 13 '16 at 14:06