收录日期:2019/12/11 02:48:36 时间:2010-10-28 22:20:47 标签:c#,fonts,metrics,font-size

The x-height is a font metric, that is given in terms of the em-height, and is approximately 0.48 of an em, but this depends on the font...

In CSS these two units are available, I am interested in the ex unit. There is also an em unit, such that the ex unit is given in terms of it.

The following table shows some metrics, available throug the following site:

http://www.cs.tut.fi/~jkorpela/x-height.html

Arial               0.519
Arial Unicode MS    0.518
Calibri             0.466
Cambria             0.466
Candara             0.463
Code2000            0.444
Comics Sans MS      0.532
Courier             0.425
Courier New         0.423
Garamond            0.384
Georgia             0.481
Helvetica           0.523
Tahoma              0.545
Times New Roman     0.448
Trebuchet MS        0.523
Verdana             0.545

I want to know the x-height of a given Font object in C#. I get the M height like this:

TextRenderer.MeasureText("M", font).Height

But I can not figure out how to get the x-height.

Using WinAPI is acceptable. It does not matter the way... browsers do this. They know how to calculate the ex value, I want to know how to get this value too. Please help!!

Thanks.

Related question that helps convert Font to Typeface:

How to convert System.Drawing.font to System.Windows.Media.Fonts or TypeFace