Remove the logical scale factor from Cairo Win32 fonts.
authorhyatt <hyatt@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 25 May 2006 22:42:09 +0000 (22:42 +0000)
committerhyatt <hyatt@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 25 May 2006 22:42:09 +0000 (22:42 +0000)
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@14599 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebCore/ChangeLog
WebCore/platform/cairo/cairo/src/cairo-win32-font.c
WebCore/platform/cairo/cairo/src/cairo-win32-private.h
WebCore/platform/cairo/font-bug-patch.txt [deleted file]
WebCore/platform/cairo/scale-removal.txt [new file with mode: 0644]
WebCore/platform/win/FontCacheWin.cpp
WebCore/platform/win/FontDataWin.cpp
WebCore/platform/win/FontPlatformData.h
WebCore/platform/win/GlyphMapWin.cpp

index 564d739622705d5bdbb183f39d9d2301f0a4a365..ed42f2ddc3d9615b3df5cfde8e43a72fed5ee15e 100644 (file)
@@ -1,3 +1,23 @@
+2006-05-25  Dave Hyatt <hyatt@apple.com>
+
+        For now eliminate the logical scale factor from Cairo.
+        This enables bitmap fonts like MS Sans Serif to work on
+        Win32.
+
+        * platform/cairo/cairo/src/cairo-win32-font.c:
+        (cairo_win32_scaled_font_select_font):
+        * platform/cairo/cairo/src/cairo-win32-private.h:
+        * platform/cairo/font-bug-patch.txt: Removed.
+        * platform/cairo/scale-removal.txt: Added.
+        * platform/win/FontCacheWin.cpp:
+        (WebCore::FontCache::createFontPlatformData):
+        * platform/win/FontDataWin.cpp:
+        (WebCore::FontData::smallCapsFontData):
+        (WebCore::FontData::platformWidthForGlyph):
+        * platform/win/FontPlatformData.h:
+        * platform/win/GlyphMapWin.cpp:
+        (WebCore::GlyphMap::fillPage):
+
 2006-05-25  Mitz Pettel  <opendarwin.org@mitzpettel.com>
 
         Reviewed by hyatt.  Landed by eseidel.
index f7629eb1cc7f137e89252873bb9b0fcaa17a89fe..1cba428dcaf0eccd0b35f6fde9751016bd6d9d9e 100644 (file)
@@ -1503,10 +1503,8 @@ cairo_win32_scaled_font_select_font (cairo_scaled_font_t *scaled_font,
        return CAIRO_STATUS_NO_MEMORY;
 
     old_hfont = SelectObject (hdc, hfont);
-    // FIXME: This error is occurring and killing all subsequent text drawing.
-    // Probably my fault, but comment it out until we're certain.
-    //if (!old_hfont)
-    // return _cairo_win32_print_gdi_error ("cairo_win32_scaled_font_select_font:SelectObject");
+    if (!old_hfont)
+       return _cairo_win32_print_gdi_error ("cairo_win32_scaled_font_select_font:SelectObject");
 
     old_mode = SetGraphicsMode (hdc, GM_ADVANCED);
     if (!old_mode) {
index c4c42ae50d5045900c9ac53cad6a4fb8ce47d5cf..309d74e8dd8032bc516d49a37436e2fa0f99d46b 100644 (file)
@@ -39,7 +39,7 @@
 #include <cairo-win32.h>
 #include <cairoint.h>
 
-#define WIN32_FONT_LOGICAL_SCALE 32
+#define WIN32_FONT_LOGICAL_SCALE 1
 
 typedef struct _cairo_win32_surface {
     cairo_surface_t base;
diff --git a/WebCore/platform/cairo/font-bug-patch.txt b/WebCore/platform/cairo/font-bug-patch.txt
deleted file mode 100644 (file)
index 9e803ac..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-Index: cairo/src/cairo-win32-font.c
-===================================================================
---- cairo/src/cairo-win32-font.c       (revision 14498)
-+++ cairo/src/cairo-win32-font.c       (working copy)
-@@ -1503,8 +1503,10 @@
-       return CAIRO_STATUS_NO_MEMORY;
-     old_hfont = SelectObject (hdc, hfont);
--    if (!old_hfont)
--      return _cairo_win32_print_gdi_error ("cairo_win32_scaled_font_select_font:SelectObject");
-+    // FIXME: This error is occurring and killing all subsequent text drawing.
-+    // Probably my fault, but comment it out until we're certain.
-+    //if (!old_hfont)
-+    //        return _cairo_win32_print_gdi_error ("cairo_win32_scaled_font_select_font:SelectObject");
-     old_mode = SetGraphicsMode (hdc, GM_ADVANCED);
-     if (!old_mode) {
diff --git a/WebCore/platform/cairo/scale-removal.txt b/WebCore/platform/cairo/scale-removal.txt
new file mode 100644 (file)
index 0000000..47c0d70
--- /dev/null
@@ -0,0 +1,13 @@
+Index: cairo/src/cairo-win32-private.h
+===================================================================
+--- cairo/src/cairo-win32-private.h    (revision 14582)
++++ cairo/src/cairo-win32-private.h    (working copy)
+@@ -39,7 +39,7 @@
+ #include <cairo-win32.h>
+ #include <cairoint.h>
+-#define WIN32_FONT_LOGICAL_SCALE 32
++#define WIN32_FONT_LOGICAL_SCALE 1
+ typedef struct _cairo_win32_surface {
+     cairo_surface_t base;
index 83211ee31a6e62be82e4979d5382eedb8aad5077..eb8565f90715ef1e5d43b6de2f829ff5ae8672c4 100755 (executable)
@@ -103,14 +103,14 @@ FontPlatformData* FontCache::createFontPlatformData(const FontDescription& fontD
     LOGFONT winfont;
 
     // The size here looks unusual.  The negative number is intentional.  The logical size constant is 32.
-    winfont.lfHeight = WIN32_FONT_LOGICAL_SCALE * -fontDescription.computedPixelSize();
+    winfont.lfHeight = -fontDescription.computedPixelSize();
     winfont.lfWidth = 0;
     winfont.lfEscapement = 0;
     winfont.lfOrientation = 0;
     winfont.lfUnderline = false;
     winfont.lfStrikeOut = false;
     winfont.lfCharSet = DEFAULT_CHARSET;
-    winfont.lfOutPrecision = OUT_DEFAULT_PRECIS;
+    winfont.lfOutPrecision = OUT_TT_PRECIS;
     winfont.lfQuality = 5; // Force cleartype.
     winfont.lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE;
     winfont.lfItalic = fontDescription.italic();
index 8ba583423368bc9354bbf891b204eae7fa0fa2a7..cdbc6bce08debd80e6a142fd908ac422631eb2a4 100755 (executable)
@@ -100,7 +100,7 @@ FontData* FontData::smallCapsFontData(const FontDescription& fontDescription) co
         LOGFONT winfont;
         GetObject(m_font.hfont(), sizeof(LOGFONT), &winfont);
         int smallCapsHeight = lroundf(0.70f * fontDescription.computedSize());
-        winfont.lfHeight = -WIN32_FONT_LOGICAL_SCALE * smallCapsHeight;
+        winfont.lfHeight = -smallCapsHeight;
         HFONT hfont = CreateFontIndirect(&winfont);
         m_smallCapsFontData = new FontData(FontPlatformData(hfont, smallCapsHeight));
     }
@@ -148,7 +148,6 @@ float FontData::platformWidthForGlyph(Glyph glyph) const
     ReleaseDC(0, dc);
 
     const double metricsMultiplier = cairo_win32_scaled_font_get_metrics_factor(scaledFont) * m_font.size();
-
     return width * metricsMultiplier;
 }
 
index 5911ceb066d7582df55583fd03fb94096e75974f..549a478bfded02ed1b1011d3c56d75e371c579fc 100755 (executable)
@@ -30,8 +30,6 @@ typedef struct HFONT__ *HFONT;
 typedef struct _cairo_scaled_font cairo_scaled_font_t;
 typedef struct _cairo_font_face cairo_font_face_t;
 
-#define WIN32_FONT_LOGICAL_SCALE 32
-
 namespace WebCore {
 
 class FontDescription;
index 585322678fbda2f7e796f7c30a46931239d1d673..2dd405a10e5c153f23e10af7ea46ee10645aa509 100755 (executable)
@@ -42,22 +42,10 @@ bool GlyphMap::fillPage(GlyphPage* page, UChar* buffer, unsigned bufferLength, c
 
     TEXTMETRIC tm;
     GetTextMetrics(dc, &tm);
-    if ((tm.tmPitchAndFamily & TMPF_VECTOR) == 0) {
-        // The "glyph" for a bitmap font is just the character itself.
-        // FIXME: Need to check character ranges and fill in a glyph of 0 for
-        // any characters not in range.  Otherwise bitmap fonts will never fall
-        // back.
-        // IMLangFontLink2::GetFontUnicodeRanges does what we want. 
-        for (unsigned i = 0; i < cGlyphPageSize; i++)
-            page->setGlyphDataForIndex(i, buffer[i], fontData);
-    } else {
-        WORD localGlyphBuffer[cGlyphPageSize];
-        GetGlyphIndices(dc, buffer, bufferLength, localGlyphBuffer, 0);
-
-        for (unsigned i = 0; i < cGlyphPageSize; i++)
-            page->setGlyphDataForIndex(i, localGlyphBuffer[i], fontData);
-    }
-
+    WORD localGlyphBuffer[cGlyphPageSize];
+    GetGlyphIndices(dc, buffer, bufferLength, localGlyphBuffer, 0);
+    for (unsigned i = 0; i < cGlyphPageSize; i++)
+        page->setGlyphDataForIndex(i, localGlyphBuffer[i], fontData);
     RestoreDC(dc, -1);
     ReleaseDC(0, dc);
     return true;