Move font destruction for HFONTs and cairo objects into FontData.
authorhyatt <hyatt@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 24 May 2006 21:54:30 +0000 (21:54 +0000)
committerhyatt <hyatt@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 24 May 2006 21:54:30 +0000 (21:54 +0000)
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@14566 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebCore/ChangeLog
WebCore/platform/win/FontDataWin.cpp
WebCore/platform/win/FontPlatformDataWin.cpp

index f2adae1f561b8b49dc5cfae3acf763cfc532cab1..c72e8a9a22364b06ceb9e797027b134cbe8d37d3 100644 (file)
@@ -1,3 +1,15 @@
+2006-05-24  Dave Hyatt <hyatt@apple.com>
+
+        Fix the font cache corruption problems on Win32.  Move the
+        native font destruction code out of FontPlatformData and
+        into FontData.  Implement smallCaps.
+
+        * platform/win/FontDataWin.cpp:
+        (WebCore::FontData::platformDestroy):
+        (WebCore::FontData::smallCapsFontData):
+        * platform/win/FontPlatformDataWin.cpp:
+        (WebCore::FontPlatformData::~FontPlatformData):
+
 2006-05-24  Anders Carlsson  <acarlsson@apple.com>
 
         Reviewed by Maciej.
index 77d24d4be1984e7292c66d649f5fc2a73eb23abd..5b059ddbbd13f4299e3866cb555080051837b13b 100755 (executable)
@@ -76,14 +76,24 @@ void FontData::platformInit()
 
 void FontData::platformDestroy()
 {
+    cairo_font_face_destroy(m_font.fontFace());
+    cairo_scaled_font_destroy(m_font.scaledFont());
+    DeleteObject(m_font.hfont());
+
     // We don't hash this on Win32, so it's effectively owned by us.
     delete m_smallCapsFontData;
 }
 
 FontData* FontData::smallCapsFontData(const FontDescription& fontDescription) const
 {
-    if (!m_smallCapsFontData)
-        return (FontData*)this; // FIXME: Implement.
+    if (!m_smallCapsFontData) {
+        LOGFONT winfont;
+        GetObject(m_font.hfont(), sizeof(LOGFONT), &winfont);
+        int smallCapsHeight = lroundf(0.70f * fontDescription.computedSize());
+        winfont.lfHeight = -WIN32_FONT_LOGICAL_SCALE * smallCapsHeight;
+        HFONT hfont = CreateFontIndirect(&winfont);
+        m_smallCapsFontData = new FontData(FontPlatformData(hfont, smallCapsHeight));
+    }
     return m_smallCapsFontData;
 }
 
index d5ef5d5f4978112532b7f2737b87f186a0015bd4..a07aa1d5f802dfa81a8d6fbfd818170184c3b27a 100644 (file)
@@ -46,11 +46,6 @@ FontPlatformData::FontPlatformData(HFONT font, int size)
     
 FontPlatformData::~FontPlatformData()
 {
-    if (m_font && m_font != (HFONT)-1) {
-        cairo_font_face_destroy(m_fontFace);
-        cairo_scaled_font_destroy(m_scaledFont);
-        DeleteObject(m_font);
-    }
 }
 
 }