Alexandre Julliard : gdi32: Fix handling of font orientation in advanced graphics mode.

Alexandre Julliard julliard at winehq.org
Mon Dec 10 14:00:38 CST 2012


Module: wine
Branch: master
Commit: b057c5f1401405d5b66a5c64835abb0f69b8e056
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=b057c5f1401405d5b66a5c64835abb0f69b8e056

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Mon Dec 10 14:33:53 2012 +0100

gdi32: Fix handling of font orientation in advanced graphics mode.

---

 dlls/gdi32/dc.c              |    2 ++
 dlls/gdi32/dibdrv/graphics.c |    8 ++++++--
 dlls/gdi32/font.c            |   32 +++++++++++++++++---------------
 dlls/gdi32/freetype.c        |    3 ++-
 dlls/winex11.drv/xrender.c   |    8 ++++++--
 5 files changed, 33 insertions(+), 20 deletions(-)

diff --git a/dlls/gdi32/dc.c b/dlls/gdi32/dc.c
index 07d68eb..c6ba488 100644
--- a/dlls/gdi32/dc.c
+++ b/dlls/gdi32/dc.c
@@ -1051,6 +1051,8 @@ INT WINAPI SetGraphicsMode( HDC hdc, INT mode )
         dc->GraphicsMode = mode;
     }
     release_dc_ptr( dc );
+    /* font metrics depend on the graphics mode */
+    if (ret) SelectObject(dc->hSelf, GetCurrentObject(dc->hSelf, OBJ_FONT));
     return ret;
 }
 
diff --git a/dlls/gdi32/dibdrv/graphics.c b/dlls/gdi32/dibdrv/graphics.c
index d0b7a39..aadd9b5 100644
--- a/dlls/gdi32/dibdrv/graphics.c
+++ b/dlls/gdi32/dibdrv/graphics.c
@@ -499,8 +499,12 @@ static struct cached_font *add_cached_font( HDC hdc, HFONT hfont, UINT aa_flags
     GetObjectW( hfont, sizeof(font.lf), &font.lf );
     GetTransform( hdc, 0x204, &font.xform );
     font.xform.eDx = font.xform.eDy = 0;  /* unused, would break hashing */
-    if (GetGraphicsMode( hdc ) == GM_COMPATIBLE && font.xform.eM11 * font.xform.eM22 < 0)
-        font.lf.lfOrientation = -font.lf.lfOrientation;
+    if (GetGraphicsMode( hdc ) == GM_COMPATIBLE)
+    {
+        font.lf.lfOrientation = font.lf.lfEscapement;
+        if (font.xform.eM11 * font.xform.eM22 < 0)
+            font.lf.lfOrientation = -font.lf.lfOrientation;
+    }
     font.lf.lfWidth = abs( font.lf.lfWidth );
     font.aa_flags = aa_flags;
     font.hash = font_cache_hash( &font );
diff --git a/dlls/gdi32/font.c b/dlls/gdi32/font.c
index 3d67c64..3d75682 100644
--- a/dlls/gdi32/font.c
+++ b/dlls/gdi32/font.c
@@ -395,15 +395,6 @@ HFONT WINAPI CreateFontIndirectExW( const ENUMLOGFONTEXDVW *penumex )
 
     fontPtr->logfont = *plf;
 
-    if (plf->lfEscapement != plf->lfOrientation)
-    {
-        /* this should really depend on whether GM_ADVANCED is set */
-        fontPtr->logfont.lfOrientation = fontPtr->logfont.lfEscapement;
-        WARN("orientation angle %f set to "
-             "escapement angle %f for new font %p\n",
-             plf->lfOrientation/10., plf->lfEscapement/10., fontPtr);
-    }
-
     if (!(hFont = alloc_gdi_handle( fontPtr, OBJ_FONT, &font_funcs )))
     {
         HeapFree( GetProcessHeap(), 0, fontPtr );
@@ -2274,10 +2265,6 @@ BOOL WINAPI ExtTextOutW( HDC hdc, INT x, INT y, UINT flags,
                 if (dc->vport2WorldValid && dc->xformWorld2Vport.eM22 < 0)
                     desired[1].y = -desired[1].y;
             }
-            else
-            {
-                if (layout & LAYOUT_RTL) desired[1].x = -desired[1].x;
-            }
 
             deltas[i].x = desired[1].x - width.x;
             deltas[i].y = desired[1].y - width.y;
@@ -2288,6 +2275,8 @@ BOOL WINAPI ExtTextOutW( HDC hdc, INT x, INT y, UINT flags,
     }
     else
     {
+        POINT desired[2];
+
         if(!done_extents)
         {
             if(flags & ETO_GLYPH_INDEX)
@@ -2296,8 +2285,21 @@ BOOL WINAPI ExtTextOutW( HDC hdc, INT x, INT y, UINT flags,
                 GetTextExtentPointW(hdc, reordered_str, count, &sz);
             done_extents = TRUE;
         }
-        width.x = abs(INTERNAL_XWSTODS(dc, sz.cx));
-        width.y = 0;
+        desired[0].x = desired[0].y = 0;
+        desired[1].x = sz.cx;
+        desired[1].y = 0;
+        LPtoDP(hdc, desired, 2);
+        desired[1].x -= desired[0].x;
+        desired[1].y -= desired[0].y;
+
+        if (dc->GraphicsMode == GM_COMPATIBLE)
+        {
+            if (dc->vport2WorldValid && dc->xformWorld2Vport.eM11 < 0)
+                desired[1].x = -desired[1].x;
+            if (dc->vport2WorldValid && dc->xformWorld2Vport.eM22 < 0)
+                desired[1].y = -desired[1].y;
+        }
+        width = desired[1];
     }
 
     tm.tmAscent = abs(INTERNAL_YWSTODS(dc, tm.tmAscent));
diff --git a/dlls/gdi32/freetype.c b/dlls/gdi32/freetype.c
index 521e665..6f3f070 100644
--- a/dlls/gdi32/freetype.c
+++ b/dlls/gdi32/freetype.c
@@ -4578,7 +4578,7 @@ static HFONT freetype_SelectFont( PHYSDEV dev, HFONT hfont, UINT *aa_flags )
         {
             lf.lfHeight *= fabs(dcmat.eM11);
             lf.lfWidth *= fabs(dcmat.eM11);
-            dcmat.eM11 = dcmat.eM22 = 1.0;
+            dcmat.eM11 = dcmat.eM22 = dcmat.eM11 < 0 ? -1 : 1;
         }
     }
     else
@@ -4587,6 +4587,7 @@ static HFONT freetype_SelectFont( PHYSDEV dev, HFONT hfont, UINT *aa_flags )
            font scaling abilities. */
         dcmat.eM11 = dcmat.eM22 = 1.0;
         dcmat.eM21 = dcmat.eM12 = 0;
+        lf.lfOrientation = lf.lfEscapement;
         if (dc->vport2WorldValid)
         {
             if (dc->xformWorld2Vport.eM11 * dc->xformWorld2Vport.eM22 < 0)
diff --git a/dlls/winex11.drv/xrender.c b/dlls/winex11.drv/xrender.c
index 4da2eb4..293e8e2 100644
--- a/dlls/winex11.drv/xrender.c
+++ b/dlls/winex11.drv/xrender.c
@@ -884,8 +884,12 @@ static HFONT xrenderdrv_SelectFont( PHYSDEV dev, HFONT hfont, UINT *aa_flags )
     TRACE("font transform %f %f %f %f\n", lfsz.xform.eM11, lfsz.xform.eM12,
           lfsz.xform.eM21, lfsz.xform.eM22);
 
-    if (GetGraphicsMode( dev->hdc ) == GM_COMPATIBLE && lfsz.xform.eM11 * lfsz.xform.eM22 < 0)
-        lfsz.lf.lfOrientation = -lfsz.lf.lfOrientation;
+    if (GetGraphicsMode( dev->hdc ) == GM_COMPATIBLE)
+    {
+        lfsz.lf.lfOrientation = lfsz.lf.lfEscapement;
+        if (lfsz.xform.eM11 * lfsz.xform.eM22 < 0)
+            lfsz.lf.lfOrientation = -lfsz.lf.lfOrientation;
+    }
 
     /* Not used fields, would break hashing */
     lfsz.xform.eDx = lfsz.xform.eDy = 0;




More information about the wine-cvs mailing list