X-height (source code)

= X-height
{wiki}

The <x-height> is the height of the main lowercase body of a <typeface>, conventionally associated with the letter “x”. It excludes the extra extent of <ascenders> and <descenders>; the <cap height> describes a different reference. Small optical overshoots mean that not every lowercase outline without an <ascender> has exactly the same ink height.<A Glossary of Typographic Terms by Adobe>[Entry x-height: lowercase body, exclusions, variation and small overshoots]{ref}

Write $r$ for the <x-height> as a fraction of an <em>. At nominal scale $p$ <pixels per em>, its ideal scaled height is $rp$ <pixels>, before <grid fitting>. Equal <font sizes> do not force equal $r$, so changing the <typeface> can alter the apparent lowercase size.

To preserve a target height $h$ while switching to a design with ratio $r_2>0$, choose $p_2=h/r_2$. If the original ratio was $r_1$ at scale $p_1$, this becomes
$$
\boxed{p_2=p_1\frac{r_1}{r_2}.}
$$
For a hypothetical switch from $r_1=0.5$ at 16 <pixels per em> to $r_2=0.4$, the matching scale is 20 <pixels per em>. Both lowercase bodies then have ideal height 8 <pixels>. This is the geometry behind metric-based <font-size adjustment> when a fallback <font> replaces another.<CSS Fonts Module Level 4 by W3C>[Section 2.6: aspect value and the font-size-adjust scaling formula]{ref}