From 50eecadfc4d928a443548253f9f2a66d4045af92 Mon Sep 17 00:00:00 2001 From: Vincent Povirk Date: Fri, 19 Feb 2010 16:50:22 -0600 Subject: [PATCH 2/2] comdlg32: Always use screen dpi in the font dialog, even with a printer dc. --- dlls/comdlg32/fontdlg.c | 31 +++++++++++++++++++------------ dlls/comdlg32/tests/fontdlg.c | 4 ++-- 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/dlls/comdlg32/fontdlg.c b/dlls/comdlg32/fontdlg.c index db8ad62..3865d1a 100644 --- a/dlls/comdlg32/fontdlg.c +++ b/dlls/comdlg32/fontdlg.c @@ -456,6 +456,21 @@ static inline HDC CFn_GetDC(const CHOOSEFONTW *lpcf) } /************************************************************************* + * GetScreenDPI [internal] + */ +static inline int GetScreenDPI(void) +{ + HDC hdc; + int result; + + hdc = GetDC(0); + result = GetDeviceCaps(hdc, LOGPIXELSY); + ReleaseDC(0, hdc); + + return result; +} + +/************************************************************************* * CFn_ReleaseDC [internal] */ static inline void CFn_ReleaseDC(const CHOOSEFONTW *lpcf, HDC hdc) @@ -486,10 +501,8 @@ static INT AddFontStyle( const ENUMLOGFONTEXW *lpElfex, const NEWTEXTMETRICEXW * if (nFontType & RASTER_FONTTYPE) { INT points; - if(!(hdc = CFn_GetDC(lpcf))) return 0; points = MulDiv( lpNTM->ntmTm.tmHeight - lpNTM->ntmTm.tmInternalLeading, - 72, GetDeviceCaps(hdc, LOGPIXELSY)); - CFn_ReleaseDC(lpcf, hdc); + 72, GetScreenDPI()); i = AddFontSizeToCombo3(hcmb3, points, lpcf); if(i) return 0; } else if (SetFontSizesToCombo3(hcmb3, lpcf)) return 0; @@ -705,7 +718,7 @@ static LRESULT CFn_WMInitDialog(HWND hDlg, WPARAM wParam, LPARAM lParam, LPCHOOS lpxx->lfHeight; INT points; int charset = lpxx->lfCharSet; - points = MulDiv( height, 72, GetDeviceCaps(hdc, LOGPIXELSY)); + points = MulDiv( height, 72, GetScreenDPI()); pstyle = MAKELONG(lpxx->lfWeight > FW_MEDIUM ? FW_BOLD: FW_NORMAL,lpxx->lfItalic !=0); SendDlgItemMessageW(hDlg, cmb1, CB_SETCURSEL, j, 0); @@ -982,14 +995,8 @@ static LRESULT CFn_WMCommand(HWND hDlg, WPARAM wParam, LPARAM lParam, LPCHOOSEFO CB_GETITEMDATA , i, 0)); else lpcf->iPointSize = 100; - hdc = CFn_GetDC(lpcf); - if( hdc) - { - lpxx->lfHeight = - MulDiv( lpcf->iPointSize , - GetDeviceCaps(hdc, LOGPIXELSY), 720); - CFn_ReleaseDC(lpcf, hdc); - } else - lpxx->lfHeight = -lpcf->iPointSize / 10; + lpxx->lfHeight = - MulDiv( lpcf->iPointSize , + GetScreenDPI(), 720); i=SendDlgItemMessageW(hDlg, cmb5, CB_GETCURSEL, 0, 0); if (i!=CB_ERR) lpxx->lfCharSet=SendDlgItemMessageW(hDlg, cmb5, CB_GETITEMDATA, i, 0); diff --git a/dlls/comdlg32/tests/fontdlg.c b/dlls/comdlg32/tests/fontdlg.c index d6819fc..57c1d90 100644 --- a/dlls/comdlg32/tests/fontdlg.c +++ b/dlls/comdlg32/tests/fontdlg.c @@ -135,8 +135,8 @@ static void test_ChooseFontA(void) expected_lfheight = -MulDiv(expected_pointsize, dpiy, 720); ok(ret == TRUE, "ChooseFontA returned FALSE\n"); - todo_wine ok(cfa.iPointSize == expected_pointsize, "Expected %i, got %i\n", expected_pointsize, cfa.iPointSize); - todo_wine ok(lfa.lfHeight == expected_lfheight, "Expected %i, got %i\n", expected_lfheight, lfa.lfHeight); + ok(cfa.iPointSize == expected_pointsize, "Expected %i, got %i\n", expected_pointsize, cfa.iPointSize); + ok(lfa.lfHeight == expected_lfheight, "Expected %i, got %i\n", expected_lfheight, lfa.lfHeight); ok(lfa.lfWeight == FW_NORMAL, "Expected FW_NORMAL, got %i\n", lfa.lfWeight); ok(strcmp(lfa.lfFaceName, "Symbol") == 0, "Expected Symbol, got %s\n", lfa.lfFaceName); -- 1.6.3.3