如何计算字体大小?

问题描述:

我有一个复杂的js函数与一个方程,其中我实际上需要了解以像素字体大小占用多少空间。

I have a complex js function with an equation in which I actually need to understand how much space in pixels font sizes take up.

我注意到一些字体

如何计算字体大小?如果它设置为 12px ,在css中, 12px 是什么意思?是 12px 宽吗?高?或者是对角像素测量?

How is a font's size calculated? If its set to 12px, in css, what does the 12px mean? Is that 12px wide? High? Or is it a diagonal pixel measurement?

请参阅 spec


字体大小对应于em
方块,这是在排版中使用的概念。

请注意,某些字形可能会在其正方形之外出现

The font size corresponds to the em square, a concept used in typography.
Note that certain glyphs may bleed outside their em squares.