Win32 DrawText line height
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
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.
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.
精彩评论