Typophile

about the x-height of certain fonts

swatch

Hi everyone,

Does anyone know how to get value of x-height of certain fonts? say Times
New Roman, etc..

I know there is some functions such as GetTextMetrics, we can use it to get
the height, the ascent and descent of fonts? but how about x-height?

Thanks a lot!

you could always measure it... that's what i tell my students...

Have you considered checking the height of the string "x"?

Thank you very much for your reply.

Yes, I think it could be done by measuring the height of x.
I mean is there any fuctions could do it? like GetTextMetrics?

How do you do it? What is the common method to get it? You do it by measuring it in font bitmaps( first write in some types and save it into bitmaps(say 32*32), then check its height) or reading directly from true type font file?

Thanks!

The best way, in most fonts, to get the x-height algorithmically.

Get the bounding box of the lower-case "o"; take the height. Subtract the overshoot below the baseline.

Cheers,

T

But doesn't the o typically also have overshoot above the x-height level? Maybe a better approximation would be to take the height of the o and subtract twice the overshoot below the baseline.

(BTW, why not just measure the height of the x itself? Do the serifs sometimes get in the way?)

Swatch,

what programming environment do you work in? What language? What operating system?

A.

Thanks for all the replying.

Hi twardoch,

I am using VC++6.0, windows XP, languages are C++ and java.
Any advices?

Thanks!

Yes, the serifs sometimes get in the way.

When I said the "height" of the "o" I really meant the "maximum Y coordinate" - so you only need to subtract the overshoot once, becase the lower overshoot isn't getting counted in the Y-max in the first place.

Cheers,

T

There are various software libraries that allow you to access font files directly (rather than calling the Windows API for some information on installed fonts). I think using FreeType 2 would be easiest since it provides object-oriented access to both OpenType/TrueType and Type 1 fonts:
http://www.freetype.org/freetype2/index.html

For TrueType or OpenType fonts, you can read out the x-height included in the font using
http://freetype.sourceforge.net/freetype2/docs/reference/ft2-truetype_ta... -- see sxHeight

I recommend joining the FreeType discussion list to get more help.

Regards,
A.

Hi twardoch,

Thanks for your information. I will definitely check them out.

Thank you!

Captured from web.archive.org on 7 Nov 2013. view this capture