views:

337

answers:

2

I'm calling the Win32 DrawText function to output some text into a device context. The text is long and wraps nicely onto a second line. The problem is I need to decrease the space between lines a bit (I guess decrease the line height?). Any ideas on how to do this?

I would just call DrawText twice (one for each line) but then I have to do my own word wrap.

Is there any other way?

Thanks

+3  A: 

It's been quite a while since I dealt with this on Win32, but I believe the font itself defines the "expected" spacing by defining empty space below the character. Drawtext uses this full "height to position the next line when wrapping. If you want to do something which is not in alignment with this sizing, I believe you will have to do your own wrapping calculations and multiple DrawText() calls.

cdkMoose
Correct, GDI spaces lines automatically based on font metrics. I've never seen anything that would allow you to modify the spacing used by `DrawText`, short of creating a modified copy of the font.
Tim Sylvester
+1  A: 

One possibility is to put the text into a disabled Rich Edit Control. I think that gives you a lot of control over formatting.

If you do write your own word wrap, you probably want to use GetTextExtentExPoint() for measuring how much will fit in each line.

Adrian McCarthy