X11DRV_ExtTextOut bug

Eric Frias efrias at syncad.com
Wed Nov 9 15:56:31 CST 2005


ExtTextOut() displays the text incorrectly if you pass in a non-NULL 
value for the final parameter, lpDx.  Each value in the array specifies 
the width of the corresponding character in the string.  This 
implemented by calling XDrawText with an array of one-character-long 
items, using the lpDx value for each character as the delta value for 
the item.  This isn't valid -- a delta tells X to put that much space 
before the item, starting at the end of the last item (not the beginning 
of the last item).  So this ExtTextOut() always ends up adding unwanted 
spaces between letters in the output.

This patch replaces the single call to XDrawText() with a loop that 
calls XDrawText once for each character.  I'm no expert on X, so maybe 
there's a more efficient way to do this.

I gave a quick look at the ExtTextOut implementations in xrender, mfdrv, 
and enhmfdrv, and I think they're correct already.

Eric
-------------- next part --------------
Index: dlls/x11drv/text.c
===================================================================
--- dlls/x11drv/text.c	(revision 31537)
+++ dlls/x11drv/text.c	(working copy)
@@ -128,25 +128,15 @@
         }
         else
         {
-            XTextItem16 *items, *pitem;
-
-            pitem = items = HeapAlloc( GetProcessHeap(), 0,
-                                       count * sizeof(XTextItem16) );
-            if(items == NULL) goto FAIL;
-
+            int offset = 0;
             for(i = 0; i < count; i++)
             {
-                pitem->chars  = str2b + i;
-                pitem->delta  = lpDx[i];
-                pitem->nchars = 1;
-                pitem->font   = None;
-                pitem++;
+                X11DRV_cptable[pfo->fi->cptable].pDrawString(
+                       pfo, gdi_display, physDev->drawable, physDev->gc,
+                       physDev->org.x + x + offset, physDev->org.y + y, 
+                       str2b+i, 1);
+                offset += lpDx[i];
             }
-
-            X11DRV_cptable[pfo->fi->cptable].pDrawText( pfo, gdi_display,
-                                  physDev->drawable, physDev->gc,
-                                  physDev->org.x + x, physDev->org.y + y, items, pitem - items );
-            HeapFree( GetProcessHeap(), 0, items );
         }
     }
     else /* rotated */


More information about the wine-patches mailing list