views:

32

answers:

1

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

+1  A: 

Check out the GlyphTypeface Class or FamilyTypeface Class.

Mark Ransom
Both classes provide a XHeight property. Thanks... that is the way to go. It also has many other interesting properties, regarding font metrics. Though it is for WPF, it is easy to convert a System.Drawing.Font object into a System.Windows.Media.Typeface. I have changed my question to include a link to a related question here in SO.
Miguel Angelo
Why can't I edit my own comment to correct english??? Why SO?? Whyyyyy???
Miguel Angelo