<rdar://problem/5651534> REGRESSION(r28764-r28765): GDI leak drawing text...
authorsfalken@apple.com <sfalken@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 18 Dec 2007 22:56:48 +0000 (22:56 +0000)
committersfalken@apple.com <sfalken@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 18 Dec 2007 22:56:48 +0000 (22:56 +0000)
        Our captured metafile from Uniscribe may contain multiple calls to CreateFontIndirect.
        Only create a font with the last one.

        Reviewed by Mitz, Darin.

        * platform/graphics/win/FontCacheWin.cpp:
        (WebCore::metaFileEnumProc):
        (WebCore::FontCache::getFontDataForCharacters):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@28838 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebCore/ChangeLog
WebCore/platform/graphics/win/FontCacheWin.cpp

index e04030d74919ceb7dd979dce04b9fa8c21b66667..ce8ab5d6202abcfad10485ac3f78f48f57cfc83e 100644 (file)
@@ -1,3 +1,16 @@
+2007-12-18  Steve Falkenburg  <sfalken@apple.com>
+
+        <rdar://problem/5651534> REGRESSION(r28764-r28765): GDI leak drawing text when no appropriate font is available
+        
+        Our captured metafile from Uniscribe may contain multiple calls to CreateFontIndirect.
+        Only create a font with the last one.
+        
+        Reviewed by Mitz, Darin.
+
+        * platform/graphics/win/FontCacheWin.cpp:
+        (WebCore::metaFileEnumProc):
+        (WebCore::FontCache::getFontDataForCharacters):
+
 2007-12-17  Brent Fulgham  <bfulgham@gmail.com>
 
         Reviewed by Darin.
index c7381dac27432a7ad8e2ba16b650266629cac38c..71675f7d1a57e3faffbf30ebc41875a84d12ffa3 100644 (file)
@@ -63,11 +63,11 @@ IMLangFontLink2* FontCache::getFontLinkInterface()
     return langFontLink;
 }
 
-static int CALLBACK metaFileEnumProc(HDC hdc, HANDLETABLE* table, CONST ENHMETARECORD* record, int tableEntries, LPARAM hfontPtr)
+static int CALLBACK metaFileEnumProc(HDC hdc, HANDLETABLE* table, CONST ENHMETARECORD* record, int tableEntries, LPARAM logFont)
 {
     if (record->iType == EMR_EXTCREATEFONTINDIRECTW) {
         const EMREXTCREATEFONTINDIRECTW* createFontRecord = reinterpret_cast<const EMREXTCREATEFONTINDIRECTW*>(record);
-        *reinterpret_cast<HFONT*>(hfontPtr) = CreateFontIndirect(&createFontRecord->elfw.elfLogFont);
+        *reinterpret_cast<LOGFONT*>(logFont) = createFontRecord->elfw.elfLogFont;
     }
     return true;
 }
@@ -134,8 +134,13 @@ const FontData* FontCache::getFontDataForCharacters(const Font& font, const UCha
             ScriptStringFree(&ssa);
         }
         HENHMETAFILE metaFile = CloseEnhMetaFile(metaFileDc);
-        if (scriptStringOutSucceeded)
-            EnumEnhMetaFile(0, metaFile, metaFileEnumProc, &hfont, NULL);
+        if (scriptStringOutSucceeded) {
+            LOGFONT logFont;
+            logFont.lfFaceName[0] = 0;
+            EnumEnhMetaFile(0, metaFile, metaFileEnumProc, &logFont, NULL);
+            if (logFont.lfFaceName[0])
+                hfont = CreateFontIndirect(&logFont);
+        }
         DeleteEnhMetaFile(metaFile);
     }