[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.0.1-3

Mike Hommey glandium at debian.org
Sat Sep 20 11:40:09 UTC 2008


The following commit has been merged in the debian/unstable branch:
commit 1b8b36b08082175923ebcef5d059d9fb63f03059
Author: Mike Hommey <glandium at debian.org>
Date:   Sat Sep 20 11:50:15 2008 +0200

    2008-09-09  Alp Toker  <alp at nuanti.com>
    
            Reviewed by Dave Hyatt.
    
            https://bugs.webkit.org/show_bug.cgi?id=16792
            [GTK] Fails to render Japanese/Chinese text with simple path
    
            https://bugs.webkit.org/show_bug.cgi?id=16942
            [GTK] Oddities in font selection and fall back
    
            https://bugs.webkit.org/show_bug.cgi?id=16862
            [GTK] Custom fonts hard-coded to use grayscale antialiasing and no hinting
    
            GTK+ font fixes and enhancements.
    
            Implement font fallback for the simple FontConfig-based text path and
            improve the Pango-based complex text path to make use of requested
            font properties and available font selection.
    
            Add text shadow support to the complex path.
    
            * platform/graphics/gtk/FontCacheGtk.cpp:
            (WebCore::FontCache::getFontDataForCharacters):
            (WebCore::FontCache::getSimilarFontPlatformData):
            * platform/graphics/gtk/FontGtk.cpp:
            (WebCore::setPangoAttributes):
            (WebCore::Font::drawComplexText):
            (WebCore::getDefaultPangoLayout):
            (WebCore::Font::floatWidthForComplexText):
            (WebCore::Font::offsetForPositionForComplexText):
            (WebCore::Font::selectionRectForComplexText):
            * platform/graphics/gtk/FontPlatformData.h:
            (WebCore::FontPlatformData::FontPlatformData):
            (WebCore::FontPlatformData::hash):
            * platform/graphics/gtk/FontPlatformDataGtk.cpp:
            (WebCore::FontPlatformData::FontPlatformData):
            * platform/graphics/gtk/SimpleFontDataGtk.cpp:
            (WebCore::SimpleFontData::platformDestroy):
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@36309 268f45cc-cd09-0410-ab3c-d52691b4dbfc
    filter-origin: adbbd78aef2282bb233a64c1578b87f8c2cf3490
    
    Conflicts:
    
    	WebCore/ChangeLog

diff --git a/WebCore/platform/graphics/gtk/FontCacheGtk.cpp b/WebCore/platform/graphics/gtk/FontCacheGtk.cpp
index 044c259..22ad1cf 100644
--- a/WebCore/platform/graphics/gtk/FontCacheGtk.cpp
+++ b/WebCore/platform/graphics/gtk/FontCacheGtk.cpp
@@ -1,31 +1,21 @@
 /*
- * Copyright (C) 2006 Apple Computer, Inc.  All rights reserved.
- * Copyright (C) 2006 Michael Emmel mike.emmel at gmail.com
- * All rights reserved.
+ * Copyright (C) 2008 Alp Toker <alp at atoker.com>
  *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
  *
- * 1.  Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- * 2.  Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- *     its contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
  *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
 #include "config.h"
@@ -45,12 +35,33 @@ void FontCache::platformInit()
 
 const SimpleFontData* FontCache::getFontDataForCharacters(const Font& font, const UChar* characters, int length)
 {
-    return new SimpleFontData(FontPlatformData(font.fontDescription(), font.family().family()));
+#if defined(USE_FREETYPE)
+    FcResult fresult;
+    FontPlatformData* prim = const_cast<FontPlatformData*>(&font.primaryFont()->m_font);
+
+    if (!prim->m_fallbacks)
+        prim->m_fallbacks = FcFontSort(NULL, prim->m_pattern, FcTrue, NULL, &fresult);
+
+    FcFontSet* fs = prim->m_fallbacks;
+
+    for (int i = 0; i < fs->nfont; i++) {
+        FcPattern* fin = FcFontRenderPrepare(NULL, prim->m_pattern, fs->fonts[i]);
+        cairo_font_face_t* fontFace = cairo_ft_font_face_create_for_pattern(fin);
+        FontPlatformData alternateFont(fontFace, font.fontDescription().computedPixelSize(), false, false);
+        cairo_font_face_destroy(fontFace);
+        alternateFont.m_pattern = fin;
+        SimpleFontData* sfd = getCachedFontData(&alternateFont);
+        if (sfd->containsCharacters(characters, length))
+            return sfd;
+    }
+#endif
+
+    return 0;
 }
 
 FontPlatformData* FontCache::getSimilarFontPlatformData(const Font& font)
 {
-    return new FontPlatformData(font.fontDescription(), font.family().family());
+    return 0;
 }
 
 FontPlatformData* FontCache::getLastResortFallbackFont(const FontDescription& fontDescription)
diff --git a/WebCore/platform/graphics/gtk/FontGtk.cpp b/WebCore/platform/graphics/gtk/FontGtk.cpp
index d73dcb2..c4ff0ab 100644
--- a/WebCore/platform/graphics/gtk/FontGtk.cpp
+++ b/WebCore/platform/graphics/gtk/FontGtk.cpp
@@ -5,6 +5,7 @@
  * Copyright (c) 2007 Kouhei Sutou
  * Copyright (C) 2007 Alp Toker <alp at atoker.com>
  * Copyright (C) 2008 Xan Lopez <xan at gnome.org>
+ * Copyright (C) 2008 Nuanti Ltd.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -37,8 +38,12 @@
 #include "SimpleFontData.h"
 
 #include <cairo.h>
+#include <gdk/gdk.h>
 #include <pango/pango.h>
 #include <pango/pangocairo.h>
+#if defined(USE_FREETYPE)
+#include <pango/pangofc-fontmap.h>
+#endif
 
 namespace WebCore {
 
@@ -133,10 +138,29 @@ static gchar* convertUniCharToUTF8(const UChar* characters, gint length, int fro
 
 static void setPangoAttributes(const Font* font, const TextRun& run, PangoLayout* layout)
 {
+#if defined(USE_FREETYPE)
+    if (font->primaryFont()->m_font.m_pattern) {
+        PangoFontDescription* desc = pango_fc_font_description_from_pattern(font->primaryFont()->m_font.m_pattern, FALSE);
+        pango_layout_set_font_description(layout, desc);
+        pango_font_description_free(desc);
+    }
+#elif defined(USE_PANGO)
+    if (font->primaryFont()->m_font.m_font) {
+        PangoFontDescription* desc = pango_font_describe(font->primaryFont()->m_font.m_font);
+        pango_layout_set_font_description(layout, desc);
+        pango_font_description_free(desc);
+    }
+#endif
+
+    pango_layout_set_auto_dir(layout, FALSE);
+
+    PangoContext* pangoContext = pango_layout_get_context(layout);
+    PangoDirection direction = run.rtl() ? PANGO_DIRECTION_RTL : PANGO_DIRECTION_LTR;
+    pango_context_set_base_dir(pangoContext, direction);
     PangoAttrList* list = pango_attr_list_new();
     PangoAttribute* attr;
 
-    attr = pango_attr_size_new_absolute((int)(font->size() * PANGO_SCALE));
+    attr = pango_attr_size_new_absolute(font->pixelSize() * PANGO_SCALE);
     attr->end_index = G_MAXUINT;
     pango_attr_list_insert_before(list, attr);
 
@@ -151,50 +175,106 @@ static void setPangoAttributes(const Font* font, const TextRun& run, PangoLayout
 
     pango_layout_set_attributes(layout, list);
     pango_attr_list_unref(list);
-
-    pango_layout_set_auto_dir(layout, FALSE);
-
-    PangoContext* pangoContext = pango_layout_get_context(layout);
-    PangoDirection direction = run.rtl() ? PANGO_DIRECTION_RTL : PANGO_DIRECTION_LTR;
-    pango_context_set_base_dir(pangoContext, direction);
 }
 
 void Font::drawComplexText(GraphicsContext* context, const TextRun& run, const FloatPoint& point, int from, int to) const
 {
     cairo_t* cr = context->platformContext();
     cairo_save(cr);
+    cairo_translate(cr, point.x(), point.y());
 
     PangoLayout* layout = pango_cairo_create_layout(cr);
+    setPangoAttributes(this, run, layout);
 
-    gchar* utf8 = convertUniCharToUTF8(run.characters(), run.length(), from, to);
+    gchar* utf8 = convertUniCharToUTF8(run.characters(), run.length(), 0, run.length());
     pango_layout_set_text(layout, utf8, -1);
-    g_free(utf8);
 
-    setPangoAttributes(this, run, layout);
+    // Our layouts are single line
+    PangoLayoutLine* layoutLine = pango_layout_get_line_readonly(layout, 0);
 
-    // Set the text color to use for drawing.
+    GdkRegion* partialRegion = NULL;
+    if (to - from != run.length()) {
+        // Clip the region of the run to be rendered
+        char* start = g_utf8_offset_to_pointer(utf8, from);
+        char* end = g_utf8_offset_to_pointer(start, to - from);
+        int ranges[] = {start - utf8, end - utf8};
+        partialRegion = gdk_pango_layout_line_get_clip_region(layoutLine, 0, 0, ranges, 1);
+        gdk_region_shrink(partialRegion, 0, -pixelSize());
+    }
+
+    Color fillColor = context->fillColor();
     float red, green, blue, alpha;
-    Color penColor = context->fillColor();
-    penColor.getRGBA(red, green, blue, alpha);
+
+    // Text shadow, inspired by FontMac
+    IntSize shadowSize;
+    int shadowBlur = 0;
+    Color shadowColor;
+    bool hasShadow = context->textDrawingMode() == cTextFill &&
+        context->getShadow(shadowSize, shadowBlur, shadowColor);
+
+    // TODO: Blur support
+    if (hasShadow) {
+        // Disable graphics context shadows (not yet implemented) and paint them manually
+        context->clearShadow();
+        Color shadowFillColor(shadowColor.red(), shadowColor.green(), shadowColor.blue(), shadowColor.alpha() * fillColor.alpha() / 255);
+        cairo_save(cr);
+
+        shadowFillColor.getRGBA(red, green, blue, alpha);
+        cairo_set_source_rgba(cr, red, green, blue, alpha);
+
+        cairo_translate(cr, shadowSize.width(), shadowSize.height());
+
+        if (partialRegion) {
+            gdk_cairo_region(cr, partialRegion);
+            cairo_clip(cr);
+        }
+
+        pango_cairo_show_layout_line(cr, layoutLine);
+
+        cairo_restore(cr);
+    }
+
+    fillColor.getRGBA(red, green, blue, alpha);
     cairo_set_source_rgba(cr, red, green, blue, alpha);
 
-    // Our layouts are single line
-    cairo_move_to(cr, point.x(), point.y());
-    PangoLayoutLine* layoutLine = pango_layout_get_line_readonly(layout, 0);
+    if (partialRegion) {
+        gdk_cairo_region(cr, partialRegion);
+        cairo_clip(cr);
+    }
+
     pango_cairo_show_layout_line(cr, layoutLine);
 
+    if (context->textDrawingMode() & cTextStroke) {
+        Color strokeColor = context->strokeColor();
+        strokeColor.getRGBA(red, green, blue, alpha);
+        cairo_set_source_rgba(cr, red, green, blue, alpha);
+        pango_cairo_layout_line_path(cr, layoutLine);
+        cairo_set_line_width(cr, context->strokeThickness());
+        cairo_stroke(cr);
+    }
+
+    // Re-enable the platform shadow we disabled earlier
+    if (hasShadow)
+        context->setShadow(shadowSize, shadowBlur, shadowColor);
+
+    // Pango sometimes leaves behind paths we don't want
+    cairo_new_path(cr);
+
+    if (partialRegion)
+        gdk_region_destroy(partialRegion);
+
+    g_free(utf8);
     g_object_unref(layout);
+
     cairo_restore(cr);
 }
 
-// FIXME: we should create the layout with our actual context, but it seems
-// we can't access it from here
+// We should create the layout with our actual context but we can't access it from here.
 static PangoLayout* getDefaultPangoLayout(const TextRun& run)
 {
-    PangoFontMap* map = pango_cairo_font_map_get_default();
-    PangoContext* pangoContext = pango_cairo_font_map_create_context(PANGO_CAIRO_FONT_MAP(map));
+    static PangoFontMap* map = pango_cairo_font_map_get_default();
+    static PangoContext* pangoContext = pango_cairo_font_map_create_context(PANGO_CAIRO_FONT_MAP(map));
     PangoLayout* layout = pango_layout_new(pangoContext);
-    g_object_unref(pangoContext);
 
     return layout;
 }
@@ -209,11 +289,11 @@ float Font::floatWidthForComplexText(const TextRun& run) const
 
     gchar* utf8 = convertUniCharToUTF8(run.characters(), run.length(), 0, run.length());
     pango_layout_set_text(layout, utf8, -1);
-    g_free(utf8);
 
-    int layoutWidth;
-    pango_layout_get_size(layout, &layoutWidth, 0);
-    float width = (float)layoutWidth / (double)PANGO_SCALE;
+    int width;
+    pango_layout_get_pixel_size(layout, &width, 0);
+
+    g_free(utf8);
     g_object_unref(layout);
 
     return width;
@@ -230,6 +310,9 @@ int Font::offsetForPositionForComplexText(const TextRun& run, int x, bool includ
     int index, trailing;
     pango_layout_xy_to_index(layout, x * PANGO_SCALE, 1, &index, &trailing);
     glong offset = g_utf8_pointer_to_offset(utf8, utf8 + index);
+    if (includePartialGlyphs)
+        offset += trailing;
+
     g_free(utf8);
     g_object_unref(layout);
 
@@ -238,8 +321,40 @@ int Font::offsetForPositionForComplexText(const TextRun& run, int x, bool includ
 
 FloatRect Font::selectionRectForComplexText(const TextRun& run, const IntPoint& point, int h, int from, int to) const
 {
-    notImplemented();
-    return FloatRect();
+    PangoLayout* layout = getDefaultPangoLayout(run);
+    setPangoAttributes(this, run, layout);
+
+    gchar* utf8 = convertUniCharToUTF8(run.characters(), run.length(), 0, run.length());
+    pango_layout_set_text(layout, utf8, -1);
+
+    char* start = g_utf8_offset_to_pointer(utf8, from);
+    char* end = g_utf8_offset_to_pointer(start, to - from);
+
+    if (run.ltr()) {
+        from = start - utf8;
+        to = end - utf8;
+    } else {
+        from = end - utf8;
+        to = start - utf8;
+    }
+
+    PangoLayoutLine* layoutLine = pango_layout_get_line_readonly(layout, 0);
+    int x_pos;
+
+    x_pos = 0;
+    if (from < layoutLine->length)
+        pango_layout_line_index_to_x(layoutLine, from, FALSE, &x_pos);
+    float beforeWidth = PANGO_PIXELS_FLOOR(x_pos);
+
+    x_pos = 0;
+    if (run.ltr() || to < layoutLine->length)
+        pango_layout_line_index_to_x(layoutLine, to, FALSE, &x_pos);
+    float afterWidth = PANGO_PIXELS(x_pos);
+
+    g_free(utf8);
+    g_object_unref(layout);
+
+    return FloatRect(point.x() + beforeWidth, point.y(), afterWidth - beforeWidth, h);
 }
 
 }
diff --git a/WebCore/platform/graphics/gtk/FontPlatformData.h b/WebCore/platform/graphics/gtk/FontPlatformData.h
index 6cfb1b4..efa5dd5 100644
--- a/WebCore/platform/graphics/gtk/FontPlatformData.h
+++ b/WebCore/platform/graphics/gtk/FontPlatformData.h
@@ -47,6 +47,7 @@ public:
     FontPlatformData(WTF::HashTableDeletedValueType)
 #if defined(USE_FREETYPE)
         : m_pattern(hashTableDeletedFontValue())
+        , m_fallbacks(0)
 #elif defined(USE_PANGO)
         : m_context(0)
         , m_font(hashTableDeletedFontValue())
@@ -59,6 +60,7 @@ public:
     FontPlatformData()
 #if defined(USE_FREETYPE)
         : m_pattern(0)
+        , m_fallbacks(0)
 #elif defined(USE_PANGO)
         : m_context(0)
         , m_font(0)
@@ -84,6 +86,10 @@ public:
 
     unsigned hash() const
     {
+#if defined(USE_FREETYPE)
+        if (m_pattern)
+            return FcPatternHash(m_pattern);
+#endif
         uintptr_t hashCodes[1] = { reinterpret_cast<uintptr_t>(m_scaledFont) };
         return StringImpl::computeHash(reinterpret_cast<UChar*>(hashCodes), sizeof(hashCodes) / sizeof(UChar));
     }
@@ -99,6 +105,7 @@ public:
 
 #if defined(USE_FREETYPE)
     FcPattern* m_pattern;
+    FcFontSet* m_fallbacks;
 #elif defined(USE_PANGO)
     static PangoFontMap* m_fontMap;
     static GHashTable* m_hashTable;
diff --git a/WebCore/platform/graphics/gtk/FontPlatformDataGtk.cpp b/WebCore/platform/graphics/gtk/FontPlatformDataGtk.cpp
index 15bc8b5..17d789b 100644
--- a/WebCore/platform/graphics/gtk/FontPlatformDataGtk.cpp
+++ b/WebCore/platform/graphics/gtk/FontPlatformDataGtk.cpp
@@ -37,7 +37,8 @@ namespace WebCore {
 
 FontPlatformData::FontPlatformData(const FontDescription& fontDescription, const AtomicString& familyName)
     : m_pattern(0)
-    , m_size(fontDescription.computedSize())
+    , m_fallbacks(0)
+    , m_size(fontDescription.computedPixelSize())
     , m_syntheticBold(false)
     , m_syntheticOblique(false)
     , m_scaledFont(0)
@@ -49,7 +50,7 @@ FontPlatformData::FontPlatformData(const FontDescription& fontDescription, const
     int fcslant = FC_SLANT_ROMAN;
     // FIXME: Map all FontWeight values to fontconfig weights.
     int fcweight = FC_WEIGHT_NORMAL;
-    float fcsize = fontDescription.computedSize();
+    double fcsize = fontDescription.computedPixelSize();
     if (fontDescription.italic())
         fcslant = FC_SLANT_ITALIC;
     if (fontDescription.weight() >= FontWeight600)
@@ -67,27 +68,30 @@ FontPlatformData::FontPlatformData(const FontDescription& fontDescription, const
         goto freePattern;
 
     switch (type) {
-        case FontDescription::SerifFamily:
-            fcfamily = "serif";
-            break;
-        case FontDescription::SansSerifFamily:
-            fcfamily = "sans-serif";
-            break;
-        case FontDescription::MonospaceFamily:
-            fcfamily = "monospace";
-            break;
-        case FontDescription::NoFamily:
-        case FontDescription::StandardFamily:
-        default:
-            fcfamily = "sans-serif";
+    case FontDescription::SerifFamily:
+        fcfamily = "serif";
+        break;
+    case FontDescription::SansSerifFamily:
+        fcfamily = "sans-serif";
+        break;
+    case FontDescription::MonospaceFamily:
+        fcfamily = "monospace";
+        break;
+    case FontDescription::StandardFamily:
+        fcfamily = "sans-serif";
+        break;
+    case FontDescription::NoFamily:
+    default:
+        fcfamily = NULL;
+        break;
     }
 
-    if (!FcPatternAddString(pattern, FC_FAMILY, reinterpret_cast<const FcChar8*>(fcfamily)))
-        goto freePattern;
-    if (!FcPatternAddInteger(pattern, FC_SLANT, fcslant))
+    if (fcfamily && !FcPatternAddString(pattern, FC_FAMILY, reinterpret_cast<const FcChar8*>(fcfamily)))
         goto freePattern;
     if (!FcPatternAddInteger(pattern, FC_WEIGHT, fcweight))
         goto freePattern;
+    if (!FcPatternAddInteger(pattern, FC_SLANT, fcslant))
+        goto freePattern;
     if (!FcPatternAddDouble(pattern, FC_PIXEL_SIZE, fcsize))
         goto freePattern;
 
@@ -101,7 +105,7 @@ FontPlatformData::FontPlatformData(const FontDescription& fontDescription, const
         goto freePattern;
     fontFace = cairo_ft_font_face_create_for_pattern(m_pattern);
     cairo_matrix_t ctm;
-    cairo_matrix_init_scale(&fontMatrix, fontDescription.computedSize(), fontDescription.computedSize());
+    cairo_matrix_init_scale(&fontMatrix, fontDescription.computedPixelSize(), fontDescription.computedPixelSize());
     cairo_matrix_init_identity(&ctm);
 
 #if GTK_CHECK_VERSION(2,10,0)
@@ -122,6 +126,7 @@ freePattern:
 
 FontPlatformData::FontPlatformData(float size, bool bold, bool italic)
     : m_pattern(0)
+    , m_fallbacks(0)
     , m_size(size)
     , m_syntheticBold(bold)
     , m_syntheticOblique(italic)
@@ -131,6 +136,7 @@ FontPlatformData::FontPlatformData(float size, bool bold, bool italic)
 
 FontPlatformData::FontPlatformData(cairo_font_face_t* fontFace, int size, bool bold, bool italic)
     : m_pattern(0)
+    , m_fallbacks(0)
     , m_size(size)
     , m_syntheticBold(bold)
     , m_syntheticOblique(italic)
@@ -140,15 +146,19 @@ FontPlatformData::FontPlatformData(cairo_font_face_t* fontFace, int size, bool b
     cairo_matrix_init_scale(&fontMatrix, size, size);
     cairo_matrix_t ctm;
     cairo_matrix_init_identity(&ctm);
-    cairo_font_options_t* options = cairo_font_options_create();
+    static const cairo_font_options_t* defaultOptions = cairo_font_options_create();
+    const cairo_font_options_t* options = NULL;
 
-    // We force antialiasing and disable hinting to provide consistent
-    // typographic qualities for custom fonts on all platforms.
-    cairo_font_options_set_hint_style(options, CAIRO_HINT_STYLE_NONE);
-    cairo_font_options_set_antialias(options, CAIRO_ANTIALIAS_GRAY);
+#if GTK_CHECK_VERSION(2,10,0)
+    if (GdkScreen* screen = gdk_screen_get_default())
+        options = gdk_screen_get_font_options(screen);
+#endif
+    // gdk_screen_get_font_options() returns NULL if no default options are
+    // set, so we always have to check.
+    if (!options)
+        options = defaultOptions;
 
     m_scaledFont = cairo_scaled_font_create(fontFace, &fontMatrix, &ctm, options);
-    cairo_font_options_destroy(options);
 }
 
 bool FontPlatformData::init()
diff --git a/WebCore/platform/graphics/gtk/SimpleFontDataGtk.cpp b/WebCore/platform/graphics/gtk/SimpleFontDataGtk.cpp
index a754c45..1ca3e95 100644
--- a/WebCore/platform/graphics/gtk/SimpleFontDataGtk.cpp
+++ b/WebCore/platform/graphics/gtk/SimpleFontDataGtk.cpp
@@ -62,19 +62,25 @@ void SimpleFontData::platformInit()
 
 void SimpleFontData::platformDestroy()
 {
-    if (!isCustomFont()) {
-        if (m_font.m_pattern && ((FcPattern*)-1 != m_font.m_pattern)) {
-            FcPatternDestroy(m_font.m_pattern);
-            m_font.m_pattern = 0;
-        }
+    delete m_smallCapsFontData;
 
-        if (m_font.m_scaledFont) {
-            cairo_scaled_font_destroy(m_font.m_scaledFont);
-            m_font.m_scaledFont = 0;
-        }
+    if (isCustomFont())
+        return;
+
+    if (m_font.m_pattern && ((FcPattern*)-1 != m_font.m_pattern)) {
+        FcPatternDestroy(m_font.m_pattern);
+        m_font.m_pattern = 0;
     }
 
-    delete m_smallCapsFontData;
+    if (m_font.m_fallbacks) {
+        FcFontSetDestroy(m_font.m_fallbacks);
+        m_font.m_fallbacks = 0;
+    }
+
+    if (m_font.m_scaledFont) {
+        cairo_scaled_font_destroy(m_font.m_scaledFont);
+        m_font.m_scaledFont = 0;
+    }
 }
 
 SimpleFontData* SimpleFontData::smallCapsFontData(const FontDescription& fontDescription) const

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list