From d4fb128daf76794f1295c0ff7972671abf7f0414 Mon Sep 17 00:00:00 2001
From: Ilya Shpigor <shpigor@etersoft.ru>
Date: Fri, 25 Sep 2009 14:48:26 +0400
Subject: [PATCH 1/2] gdi32: Fix size of the filling background for the text drawing

---
 dlls/gdi32/font.c |   21 +++++++++++++++------
 1 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/dlls/gdi32/font.c b/dlls/gdi32/font.c
index c81a9c8..fe6b4fe 100644
--- a/dlls/gdi32/font.c
+++ b/dlls/gdi32/font.c
@@ -1899,12 +1899,21 @@ BOOL WINAPI ExtTextOutW( HDC hdc, INT x, INT y, UINT flags,
             if(!(flags & ETO_OPAQUE) || x < rc.left || x + width >= rc.right ||
                y - tm.tmAscent < rc.top || y + tm.tmDescent >= rc.bottom)
             {
-                RECT rc;
-                rc.left = x;
-                rc.right = x + width;
-                rc.top = y - tm.tmAscent;
-                rc.bottom = y + tm.tmDescent;
-                dc->funcs->pExtTextOut(dc->physDev, 0, 0, ETO_OPAQUE, &rc, NULL, 0, NULL);
+                RECT orc;
+                orc.top = y - tm.tmAscent;
+                orc.bottom = y + tm.tmDescent;
+
+                if ((flags & ETO_CLIPPED) && (x + width >= rc.right))
+                {
+                    orc.left = rc.left;
+                    orc.right = rc.right;
+                }
+                else
+                {
+                    orc.left = x;
+                    orc.right = x + width;
+                }
+                dc->funcs->pExtTextOut(dc->physDev, 0, 0, ETO_OPAQUE, &orc, NULL, 0, NULL);
             }
         }
     }
-- 
1.6.4.2


