Win32 DrawText line height

末鹿安然 提交于 2019-12-23 15:21:39

问题


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


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/1758908/win32-drawtext-line-height

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!