Fog Creek Software
Discussion Board




GetTextExtent

And now to a mundane programming problem (I have been procrastinating about this one for a while)

I'm drawing some text with TextOut in Win32

I need to know the exact size of the text in pixels)

If I use GetTextExtent* functions, it works, except if the text is italic... in which case the width is the baseline width. For italic the last character slopes outside the box towards the top.

Any ideas?

S. Tanna
Tuesday, June 10, 2003

Add a M or W width to the number you get.

I think this might be a bug in GetTextExtent.

njkayaker
Tuesday, June 10, 2003

If you are using a raster type font then you may have to account for the overhang using GetTextMetrics.  Or you might try using GetCharWidth32 or GetCharABCWidths.

Dave B.
Tuesday, June 10, 2003

*  Recent Topics

*  Fog Creek Home