2007-12-19 Alp Toker <alp@atoker.com>
authoralp@webkit.org <alp@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 19 Dec 2007 23:22:11 +0000 (23:22 +0000)
committeralp@webkit.org <alp@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 19 Dec 2007 23:22:11 +0000 (23:22 +0000)
        Build fix for Pango < 1.18.0 breakage introduced in r28864. Use Fc and
        the Pango backend API in these cases.

        * platform/graphics/gtk/FontPlatformDataGtk.cpp:
        (WebCore::FontPlatformData::FontPlatformData):
        (WebCore::FontPlatformData::~FontPlatformData):

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

WebCore/ChangeLog
WebCore/platform/graphics/gtk/FontPlatformDataGtk.cpp

index 9c5f654acbab5528a8111ad9808e884b9c2f6e11..5a6074e0cb73b44db7fece89f51a15b6b863611f 100644 (file)
@@ -1,3 +1,12 @@
+2007-12-19  Alp Toker  <alp@atoker.com>
+
+        Build fix for Pango < 1.18.0 breakage introduced in r28864. Use Fc and
+        the Pango backend API in these cases.
+
+        * platform/graphics/gtk/FontPlatformDataGtk.cpp:
+        (WebCore::FontPlatformData::FontPlatformData):
+        (WebCore::FontPlatformData::~FontPlatformData):
+
 2007-12-19  Alice Liu  <alice.liu@apple.com>
 
         Reviewed by Darin.
index 4a192b53d1dc14724ce98dfc224838f469c68820..37ad20a9a074615d648f6b4a545280901e468264 100644 (file)
@@ -26,6 +26,9 @@
  *
  */
 
+// Use the Pango backend API for compatibility with older Pango versions.
+#define PANGO_ENABLE_BACKEND
+
 #include "config.h"
 #include "FontPlatformData.h"
 
 #include <cairo.h>
 #include <assert.h>
 
+#include <pango/pango.h>
+#include <pango/pangocairo.h>
+
+// Use cairo-ft if a recent enough Pango version isn't available.
+#if !PANGO_VERSION_CHECK(1,18,0)
+#include <cairo-ft.h>
+#include <pango/pangofc-fontmap.h>
+#endif
+
 namespace WebCore {
 
 PangoFontMap* FontPlatformData::m_fontMap = 0;
@@ -87,8 +99,31 @@ FontPlatformData::FontPlatformData(const FontDescription& fontDescription, const
     }
 
     // FIXME: should we set some default font?
+#if PANGO_VERSION_CHECK(1,18,0)
     if (m_font)
-        m_scaledFont = pango_cairo_font_get_scaled_font(PANGO_CAIRO_FONT(m_font));
+        m_scaledFont = cairo_scaled_font_reference(pango_cairo_font_get_scaled_font(PANGO_CAIRO_FONT(m_font)));
+#else
+    // This compatibility code for older versions of Pango is not well-tested.
+    if (m_font) {
+        PangoFcFont* fcfont = PANGO_FC_FONT(m_font);
+        cairo_font_face_t* face = cairo_ft_font_face_create_for_pattern(fcfont->font_pattern);
+        double size;
+        if (FcPatternGetDouble(fcfont->font_pattern, FC_PIXEL_SIZE, 0, &size) != FcResultMatch)
+            size = 12.0;
+        cairo_matrix_t fontMatrix;
+        cairo_matrix_init_scale(&fontMatrix, size, size);
+        cairo_font_options_t* fontOptions;
+        if (pango_cairo_context_get_font_options(m_context))
+            fontOptions = cairo_font_options_copy(pango_cairo_context_get_font_options(m_context));
+        else
+            fontOptions = cairo_font_options_create();
+        cairo_matrix_t ctm;
+        cairo_matrix_init_identity(&ctm);
+        m_scaledFont = cairo_scaled_font_create(face, &fontMatrix, &ctm, fontOptions);
+        cairo_font_options_destroy(fontOptions);
+        cairo_font_face_destroy(face);
+    }
+#endif
 
     pango_font_description_free(description);
 }
@@ -123,6 +158,8 @@ bool FontPlatformData::init()
 
 FontPlatformData::~FontPlatformData()
 {
+    if (m_scaledFont)
+        cairo_scaled_font_destroy(m_scaledFont);
 }
 
 bool FontPlatformData::isFixedPitch()