From d528aba0b341a115c9094628eb470ba90adafd86 Mon Sep 17 00:00:00 2001 From: "dcone%netscape.com" Date: Fri, 28 May 1999 14:13:53 +0000 Subject: [PATCH] Fixed RealizeFont() to use a screen DC when printing for a few windows calls git-svn-id: svn://10.0.0.236/trunk@33128 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/gfx/src/windows/nsFontMetricsWin.cpp | 29 +++++++++++++++----- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/mozilla/gfx/src/windows/nsFontMetricsWin.cpp b/mozilla/gfx/src/windows/nsFontMetricsWin.cpp index 1c1b2cf2f31..351d35dfacf 100644 --- a/mozilla/gfx/src/windows/nsFontMetricsWin.cpp +++ b/mozilla/gfx/src/windows/nsFontMetricsWin.cpp @@ -814,24 +814,36 @@ FontEnumCallback(const nsString& aFamily, PRBool aGeneric, void *aData) return PR_TRUE; // don't stop } +/** --------------------------------------------------- + * See documentation in nsFontMetricsWin.h + * @update 05/28/99 dwc + */ void nsFontMetricsWin::RealizeFont() { - HWND win = NULL; - HDC dc = NULL; +HWND win = NULL; +HDC dc = NULL; +HDC dc1 = NULL; - if (NULL != mDeviceContext->mDC) + + if (NULL != mDeviceContext->mDC){ + // XXX - DC If we are printing, we need to get the printer HDC and a screen HDC + // The screen HDC is because there seems to be a bug or requirment that the + // GetFontData() method call have a screen HDC, some printers HDC's return nothing + // thats will give us bad font data, and break us. dc = mDeviceContext->mDC; - else - { + win = (HWND)mDeviceContext->mWidget; + dc1 = ::GetDC(win); + } else { // Find font metrics and character widths win = (HWND)mDeviceContext->mWidget; dc = ::GetDC(win); + dc1 = dc; } mFont->EnumerateFamilies(FontEnumCallback, this); - nsFontWin* font = FindFont(dc, 'a'); + nsFontWin* font = FindFont(dc1, 'a'); if (!font) { return; } @@ -881,8 +893,11 @@ nsFontMetricsWin::RealizeFont() ::SelectObject(dc, oldfont); - if (NULL == mDeviceContext->mDC) + if (NULL == mDeviceContext->mDC){ ::ReleaseDC(win, dc); + } else { + ::ReleaseDC(win,dc1); + } } NS_IMETHODIMP