[Try 2] [3/3] riched20:EM_FORMATRANGE Implementation Patch

Dylan Smith dylan.ah.smith at gmail.com
Sun Feb 21 02:40:23 CST 2010

You accidentally sent the email for try 2 of this patch to wine-devel
instead of wine-patches.

In function ME_FormatContent in file paint.c you calculate the value
>+  numCharPrintable = c.nAvailWidth / (1440/c.dpiTarget.cy);
then use it later to set iEndOffset, the return value, when the
remainder of the text doesn't fit the page.
>+  if (iEndOffset == -1)
>+  {
>+    iEndOffset = numCharPrintable + 1;
>+    targetBottom = c.pt.y - cyOffset;
>+  }
The problem is that numCharPrintable is the width of the page in twips
but the return value is supposed to be "the index of the last
character that fits in the region, plus 1."  So the return value isn't
some value in twips, it should be a character index reflecting the
page boundary.

As I have mentioned to you before in an offlist email, this will cause
problems with applications which try to print all the pages in a loop
with cpMax=-1 to specify to print to the end of the text, and cpMin
for following calls set to the return value of preview calls to send
EM_FORMATRANGE messages.  The return value will cause an endless loop
for long enough text with more characters than the width of the page
in twips.

It happens to not break the tests, but that doesn't mean it is
correct. On my machine the tests don't even execute that condition.

I believe on your machine your machine the condition is taken in the
tests, likely because fonts on your machine must be different than on
mine.  The underlying problem with the correct approach though is that
a special case for wrapping which isn't handled properly in wine, so
this underlying problem causes the test failure which you are trying
to fix the wrong way.

More information about the wine-devel mailing list