On 2007-01-29, Duane Clark wrote:
GetTextExtentPoint32
For some examples in Wine, look at almost any control in comctl32.
I was afraid somebody would answer that... Thanks for the quick reply, but that isn't exactly what I need.
Here's the picture: when an application calls TextOut() for printing text, the usual (at least in my case) call sequence in Wine is
TextOut() TextOutA() ExtTextOutA() ExtTextOutW() (the one I patched) GetTextExtentPointW() GetTextExtentPoint32W() (the wide-char version of the one you mentioned) GetTextExtentExPointW() WineEngGetTextExtentExPoint() (the one that actually gets the individual character widths)
That is, at some point, TextOut() indirectly uses GetTextExtentPoint32() to get the dimensions, okay. But what I need is to check the text width *after* it was output by TextOut() -- in other words, after the function has returned, to see if it output the text properly. In Wine, I tried the trick of making ExtTextOutW() return the said value, and the tests passed without a hitch, which means the text is being properly justified. The problem is that such is not an acceptable way of doing things, and, to use Dan Kegel's words, that is not going to fly on Windows.
To be a bit clearer, in my tests I do call GetTextExtent32() in order to compute the remaining white space for the justification part, and what I want to check is whether TextOut() understood it right or not.
- Pedro.
"Pedro Araujo Chaves Jr." inckie@gmail.com wrote:
Here's the picture: when an application calls TextOut() for printing text, the usual (at least in my case) call sequence in Wine is
TextOut() TextOutA() ExtTextOutA() ExtTextOutW() (the one I patched) GetTextExtentPointW() GetTextExtentPoint32W() (the wide-char version of the one you mentioned) GetTextExtentExPointW() WineEngGetTextExtentExPoint() (the one that actually gets the individual character widths)
That is, at some point, TextOut() indirectly uses GetTextExtentPoint32() to get the dimensions, okay. But what I need is to check the text width *after* it was output by TextOut() -- in other words, after the function has returned, to see if it output the text properly. In Wine, I tried the trick of making ExtTextOutW() return the said value, and the tests passed without a hitch, which means the text is being properly justified. The problem is that such is not an acceptable way of doing things, and, to use Dan Kegel's words, that is not going to fly on Windows.
To be a bit clearer, in my tests I do call GetTextExtent32() in order to compute the remaining white space for the justification part, and what I want to check is whether TextOut() understood it right or not.
Then probably DrawText(DT_CALCRECT) could better suit your needs.
On 1/30/07, Dmitry Timoshkov wrote:
Then probably DrawText(DT_CALCRECT) could better suit your needs.
Almost on the bull's-eye! Actually, DrawText() returns the *height* of the string... how lucky I am, huh?
But a "See Also" link in the MSDN page for DrawText() [1] pointed me to TabbedTextOut() [2], which returns both the height and the width... I'll give it a shot, even though the comment for TEXT_TabbedTextOut() in dlls/user32/text.c [3] doesn't encourage me much... ¬¬
(I shouldn't change *that* behavior of Windows, should I? =P)
Thanks for the suggestion! Anyone else?
- Pedro.
[1] http://msdn.microsoft.com/library/en-us/gdi/fontext_0odw.asp [2] http://msdn.microsoft.com/library/en-us/gdi/fontext_001g.asp [3] It reads: /*********************************************************************** * TEXT_TabbedTextOut * * Helper function for TabbedTextOut() and GetTabbedTextExtent(). * Note: this doesn't work too well for text-alignment modes other * than TA_LEFT|TA_TOP. But we want bug-for-bug compatibility :-) */