Michael Karcher : Add support for compatibility mode in WineEngCreateFontInstance.

Alexandre Julliard julliard at winehq.org
Tue Jul 8 06:10:48 CDT 2008


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

Author: Michael Karcher <wine at mkarcher.dialup.fu-berlin.de>
Date:   Mon Jul  7 17:18:10 2008 +0200

Add support for compatibility mode in WineEngCreateFontInstance.

---

 dlls/gdi32/freetype.c   |   25 +++++++++++++++++--------
 dlls/gdi32/tests/font.c |   19 +++++++++++++++++++
 2 files changed, 36 insertions(+), 8 deletions(-)

diff --git a/dlls/gdi32/freetype.c b/dlls/gdi32/freetype.c
index 4fe468c..8cfd7aa 100644
--- a/dlls/gdi32/freetype.c
+++ b/dlls/gdi32/freetype.c
@@ -3064,7 +3064,7 @@ static void calc_hash(FONT_DESC *pfd)
     return;
 }
 
-static GdiFont *find_in_cache(HFONT hfont, const LOGFONTW *plf, const XFORM *pxf, BOOL can_use_bitmap)
+static GdiFont *find_in_cache(HFONT hfont, const LOGFONTW *plf, const FMAT2 *pmat, BOOL can_use_bitmap)
 {
     GdiFont *ret;
     FONT_DESC fd;
@@ -3072,7 +3072,7 @@ static GdiFont *find_in_cache(HFONT hfont, const LOGFONTW *plf, const XFORM *pxf
     struct list *font_elem_ptr, *hfontlist_elem_ptr;
 
     fd.lf = *plf;
-    memcpy(&fd.matrix, pxf, sizeof(FMAT2));
+    fd.matrix = *pmat;
     fd.can_use_bitmap = can_use_bitmap;
     calc_hash(&fd);
 
@@ -3240,6 +3240,7 @@ GdiFont *WineEngCreateFontInstance(DC *dc, HFONT hfont)
     LOGFONTW lf;
     CHARSETINFO csi;
     HFONTLIST *hflist;
+    FMAT2 dcmat;
     FontSubst *psub = NULL;
 
     EnterCriticalSection( &freetype_cs );
@@ -3269,13 +3270,21 @@ GdiFont *WineEngCreateFontInstance(DC *dc, HFONT hfont)
 	  lf.lfWeight, lf.lfPitchAndFamily, lf.lfCharSet, lf.lfOrientation,
 	  lf.lfEscapement);
 
-    TRACE("DC transform %f %f %f %f %f %f\n",
-          dc->xformWorld2Vport.eM11, dc->xformWorld2Vport.eM12,
-          dc->xformWorld2Vport.eM21, dc->xformWorld2Vport.eM22,
-          dc->xformWorld2Vport.eDx, dc->xformWorld2Vport.eDy);
+    if(dc->GraphicsMode == GM_ADVANCED)
+        memcpy(&dcmat, &dc->xformWorld2Vport, sizeof(FMAT2));
+    else
+    {
+        /* Windows 3.1 compatibility mode GM_COMPATIBLE has only limited
+           font scaling abilities. */
+        dcmat.eM11 = dcmat.eM22 = fabs(dc->xformWorld2Vport.eM22);
+        dcmat.eM21 = dcmat.eM12 = 0;
+    }
+
+    TRACE("DC transform %f %f %f %f\n", dcmat.eM11, dcmat.eM12,
+                                        dcmat.eM21, dcmat.eM22);
 
     /* check the cache first */
-    if((ret = find_in_cache(hfont, &lf, &dc->xformWorld2Vport, can_use_bitmap)) != NULL) {
+    if((ret = find_in_cache(hfont, &lf, &dcmat, can_use_bitmap)) != NULL) {
         TRACE("returning cached gdiFont(%p) for hFont %p\n", ret, hfont);
         LeaveCriticalSection( &freetype_cs );
         return ret;
@@ -3297,7 +3306,7 @@ GdiFont *WineEngCreateFontInstance(DC *dc, HFONT hfont)
 
     ret = alloc_font();
 
-    memcpy(&ret->font_desc.matrix, &dc->xformWorld2Vport, sizeof(FMAT2));
+    ret->font_desc.matrix = dcmat;
     ret->font_desc.lf = lf;
     ret->font_desc.can_use_bitmap = can_use_bitmap;
     calc_hash(&ret->font_desc);
diff --git a/dlls/gdi32/tests/font.c b/dlls/gdi32/tests/font.c
index 8769b2f..d143949 100644
--- a/dlls/gdi32/tests/font.c
+++ b/dlls/gdi32/tests/font.c
@@ -453,6 +453,25 @@ static void test_outline_font(void)
     ok(gm.gmCellIncY == 0, "incY %d != 0\n", gm.gmCellIncY);
     SelectObject(hdc, old_hfont);
 
+    SetMapMode(hdc, MM_ANISOTROPIC);
+    /* test restrictions of compatibility mode GM_COMPATIBLE */
+    /*  part 1: rescaling only X should not change font scaling on screen.
+                So compressing the X axis by 2 is not done, and this
+                appears as X scaling of 2 that no one requested. */
+    SetWindowExtEx(hdc, 100, 100, NULL);
+    SetViewportExtEx(hdc, 50, 100, NULL);
+    test_font_metrics(hdc, hfont, lf.lfHeight, lf.lfWidth, test_str, sizeof(test_str), &otm.otmTextMetrics, &size_orig, width_orig, 2, 1);
+
+    /*  part 2: rescaling only Y should change font scaling.
+                As also X is scaled by a factor of 2, but this is not
+                requested by the DC transformation, we get a scaling factor
+                of 2 in the X coordinate. */
+    SetViewportExtEx(hdc, 100, 200, NULL);
+    test_font_metrics(hdc, hfont, lf.lfHeight, lf.lfWidth, test_str, sizeof(test_str), &otm.otmTextMetrics, &size_orig, width_orig, 2, 1);
+
+    /* restore scaling */
+    SetMapMode(hdc, MM_TEXT);
+
     if (!SetGraphicsMode(hdc, GM_ADVANCED))
     {
         DeleteObject(hfont);




More information about the wine-cvs mailing list