DIALOG_GetCharSizeFromDC(resent)

Uwe Bonnes bon at elektron.ikp.physik.tu-darmstadt.de
Fri Jan 18 11:36:31 CST 2002


Hallo, 

appended patch (from Dec.14) hasn't been applied nor rejected. 

Changelog:
        windows/dialog: DIALOG_GetCharSizeFromDC
        Make the function behave as descibed


Remark:
For the 16 bit installer of MS Encarta 99 the size calculation still seems
wrong. On my system 
-adobe-helvetica-medium-r-normal-*-11-*-100-100-p-*-iso10646-1
is choosen, which is to small. If I force 
-adobe-helvetica-medium-r-normal-*-14-*-100-100-p-*-iso10646-1
to be choosen, the whole dialog box has the same size than in vmware/osr2, but
the font is noticable bigger. 

Bye

--
Uwe Bonnes                bon at elektron.ikp.physik.tu-darmstadt.de

Free Software: If you contribute nothing, expect nothing
--
Index: wine/windows/dialog.c
===================================================================
RCS file: /home/wine/wine/windows/dialog.c,v
retrieving revision 1.97
diff -u -w -r1.97 dialog.c
--- wine/windows/dialog.c	20 Dec 2001 00:19:43 -0000	1.97
+++ wine/windows/dialog.c	18 Jan 2002 17:27:40 -0000
@@ -142,6 +142,7 @@
  *
  *  Latest: the X font driver will now compute a proper average width
  *  so this code can be removed
+ *  bon 011214: Is "can be removed" still true?
  */
 static BOOL DIALOG_GetCharSizeFromDC( HDC hDC, HFONT hFont, SIZE * pSize )
 {
@@ -172,23 +173,21 @@
                  * how Microsoft's dialog creation code calculates the size 
                  * of the font
                  */
-                if (GetTextExtentPointA(hDC,szAvgChars,sizeof(szAvgChars),&total))
+                if (GetTextExtentPointA(hDC,szAvgChars,strlen(szAvgChars),&total))
                 {
                    /* round up */
-                    pSize->cx = ((2*total.cx/sizeof(szAvgChars)) + 1)/2;
+                    pSize->cx = (total.cx+(strlen(szAvgChars)-1))/strlen(szAvgChars);
                     Success = TRUE;
                 }
             } 
             else 
             {
+	        /* Use the text metrics */
                 Success = TRUE;
             }
-	    /* Use the text metrics */
-	    TRACE("Using tm: %ldx%ld (dlg: %ld x %ld) (%s)\n",
+	    TRACE("from font: %ldx%ld (using: %ld x %ld) (%s)\n",
                   tm.tmAveCharWidth, tm.tmHeight, pSize->cx, pSize->cy,
 		  tm.tmPitchAndFamily & TMPF_FIXED_PITCH ? "variable" : "fixed");		
-	    pSize->cx = tm.tmAveCharWidth;
-	    pSize->cy = tm.tmHeight;
         }
         /* select the original font */
         if (hFontPrev) SelectFont(hDC,hFontPrev);




More information about the wine-patches mailing list