使用不同的字体类型时如何计算字体的大小?

How can I calculate the size of font when using different font-types?

这篇文章 (Deep dive CSS: font metrics, line-height and vertical-align - Vincent De Oliveira) 说我们可以确定字体类型的 'real' px 大小,方法是添加其上升和下降并将该值与其 em-square (UPM) 进行比较。例如,在它给出的示例中,具有 1100 ascender 和 540 descender(其 UPM 为 1000)的字体类型意味着当 font-size 设置为 100px 它实际上是 164px。

你不也需要加上它的x高度吗?

Don’t you also need to add it’s x-height?

不,在文章中你可以看到:

based on its relative units, metrics of the fonts are set (ascender, descender, capital height, x-height, etc.). Note that some values can bleed outside of the em-square.

x-height 是我们可以使用的指标之一,但它已经包含在 ascender + descender 的总和中

那么您可以阅读:

We can also predict that capital letters are 68px high (680 units) and lower case letters (x-height) are 49px high (485 units). As a result, 1ex = 49px.

https://iamvdo.me/en/blog/css-font-metrics-line-height-and-vertical-align

所以内容区域是ascender和descender的总和(110px + 54px),x-height是小写字母的大小,只有49px,已经包含在内容区域中