Changeset 29418 in webkit


Ignore:
Timestamp:
Jan 11, 2008 1:58:11 PM (16 years ago)
Author:
alp@webkit.org
Message:

2008-01-11 Alp Toker <alp@atoker.com>

Reviewed by Dave Hyatt and Mark Rowe.

http://bugs.webkit.org/show_bug.cgi?id=16089
[GTK] Support custom fonts, CachedFont::platformDataFromCustomData()

Add support for CSS2 @font-face custom/downloadable fonts to the GTK+
port.

  • GNUmakefile.am:
  • WebCore.pro:
  • loader/CachedFont.cpp: (WebCore::CachedFont::~CachedFont): (WebCore::CachedFont::ensureCustomFontData): (WebCore::CachedFont::platformDataFromCustomData): (WebCore::CachedFont::allReferencesRemoved):
  • platform/graphics/gtk/FontCustomPlatformData.cpp: Added. (WebCore::FontCustomPlatformData::~FontCustomPlatformData): (WebCore::FontCustomPlatformData::fontPlatformData): (WebCore::releaseData): (WebCore::createFontCustomPlatformData):
  • platform/graphics/gtk/FontCustomPlatformData.h: Added. (WebCore::FontCustomPlatformData::FontCustomPlatformData):
  • platform/graphics/gtk/FontPlatformData.h:
  • platform/graphics/gtk/FontPlatformDataGtk.cpp: (WebCore::FontPlatformData::FontPlatformData): (WebCore::FontPlatformData::init): (WebCore::FontPlatformData::isFixedPitch):
  • platform/graphics/gtk/SimpleFontDataGtk.cpp: (WebCore::SimpleFontData::platformDestroy):
Location:
trunk/WebCore
Files:
2 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r29416 r29418  
     12008-01-11  Alp Toker  <alp@atoker.com>
     2
     3        Reviewed by Dave Hyatt and Mark Rowe.
     4
     5        http://bugs.webkit.org/show_bug.cgi?id=16089
     6        [GTK] Support custom fonts, CachedFont::platformDataFromCustomData()
     7
     8        Add support for CSS2 @font-face custom/downloadable fonts to the GTK+
     9        port.
     10
     11        * GNUmakefile.am:
     12        * WebCore.pro:
     13        * loader/CachedFont.cpp:
     14        (WebCore::CachedFont::~CachedFont):
     15        (WebCore::CachedFont::ensureCustomFontData):
     16        (WebCore::CachedFont::platformDataFromCustomData):
     17        (WebCore::CachedFont::allReferencesRemoved):
     18        * platform/graphics/gtk/FontCustomPlatformData.cpp: Added.
     19        (WebCore::FontCustomPlatformData::~FontCustomPlatformData):
     20        (WebCore::FontCustomPlatformData::fontPlatformData):
     21        (WebCore::releaseData):
     22        (WebCore::createFontCustomPlatformData):
     23        * platform/graphics/gtk/FontCustomPlatformData.h: Added.
     24        (WebCore::FontCustomPlatformData::FontCustomPlatformData):
     25        * platform/graphics/gtk/FontPlatformData.h:
     26        * platform/graphics/gtk/FontPlatformDataGtk.cpp:
     27        (WebCore::FontPlatformData::FontPlatformData):
     28        (WebCore::FontPlatformData::init):
     29        (WebCore::FontPlatformData::isFixedPitch):
     30        * platform/graphics/gtk/SimpleFontDataGtk.cpp:
     31        (WebCore::SimpleFontData::platformDestroy):
     32
    1332008-01-11  Adam Roben  <aroben@apple.com>
    234
  • trunk/WebCore/GNUmakefile.am

    r29399 r29418  
    936936        WebCore/platform/gtk/FileSystemGtk.cpp \
    937937        WebCore/platform/graphics/gtk/FontCacheGtk.cpp \
     938        WebCore/platform/graphics/gtk/FontCustomPlatformData.cpp \
    938939        WebCore/platform/graphics/gtk/FontGtk.cpp \
    939940        WebCore/platform/graphics/gtk/FontPlatformDataGtk.cpp \
  • trunk/WebCore/WebCore.pro

    r29399 r29418  
    10061006        platform/gtk/FileSystemGtk.cpp \
    10071007        platform/graphics/gtk/FontCacheGtk.cpp \
     1008        platform/graphics/gtk/FontCustomPlatformData.cpp \
    10081009        platform/graphics/gtk/FontGtk.cpp \
    10091010        platform/graphics/gtk/FontPlatformDataGtk.cpp \
  • trunk/WebCore/loader/CachedFont.cpp

    r27973 r29418  
    3131#include "CachedResourceClientWalker.h"
    3232#include "FontPlatformData.h"
    33 #if PLATFORM(CG) || PLATFORM(QT)
     33#if PLATFORM(CG) || PLATFORM(QT) || PLATFORM(GTK)
    3434#include "FontCustomPlatformData.h"
    3535#endif
     
    5050CachedFont::~CachedFont()
    5151{
    52 #if PLATFORM(CG) || PLATFORM(QT)
     52#if PLATFORM(CG) || PLATFORM(QT) || PLATFORM(GTK)
    5353    delete m_fontData;
    5454#endif
     
    8484bool CachedFont::ensureCustomFontData()
    8585{
    86 #if PLATFORM(CG) || PLATFORM(QT)
     86#if PLATFORM(CG) || PLATFORM(QT) || PLATFORM(GTK)
    8787    if (!m_fontData && !m_errorOccurred && !m_loading) {
    8888        m_fontData = createFontCustomPlatformData(m_data.get());
     
    9696FontPlatformData CachedFont::platformDataFromCustomData(int size, bool bold, bool italic)
    9797{
    98 #if PLATFORM(CG) || PLATFORM(QT)
     98#if PLATFORM(CG) || PLATFORM(QT) || PLATFORM(GTK)
    9999    ASSERT(m_fontData);
    100100    return m_fontData->fontPlatformData(size, bold, italic);
     
    106106void CachedFont::allReferencesRemoved()
    107107{
    108 #if PLATFORM(CG) || PLATFORM(QT)
     108#if PLATFORM(CG) || PLATFORM(QT) || PLATFORM(GTK)
    109109    if (m_fontData) {
    110110        delete m_fontData;
  • trunk/WebCore/platform/graphics/gtk/FontPlatformData.h

    r28921 r29418  
    5050
    5151    FontPlatformData(const FontDescription&, const AtomicString& family);
     52
     53    FontPlatformData(cairo_font_face_t* fontFace, int size, bool bold, bool italic);
     54
    5255    ~FontPlatformData();
    5356
  • trunk/WebCore/platform/graphics/gtk/FontPlatformDataGtk.cpp

    r28921 r29418  
    11/*
    2  * This file is part of the internal font implementation.  It should not be included by anyone other than
    3  * FontMac.cpp, FontWin.cpp and Font.cpp.
    4  *
    52 * Copyright (C) 2006 Apple Computer, Inc.
    63 * Copyright (C) 2006 Michael Emmel mike.emmel@gmail.com
    7  * Copyright (C) 2007 Alp Toker <alp@atoker.com>
     4 * Copyright (C) 2007, 2008 Alp Toker <alp@atoker.com>
    85 * Copyright (C) 2007 Holger Hans Peter Freyther
    96 * All rights reserved.
     
    2320 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
    2421 * Boston, MA 02110-1301, USA.
    25  *
    2622 */
    2723
     
    112108}
    113109
     110FontPlatformData::FontPlatformData(cairo_font_face_t* fontFace, int size, bool bold, bool italic)
     111    : m_pattern(0)
     112    , m_fontDescription()
     113    , m_scaledFont(0)
     114{
     115    cairo_matrix_t fontMatrix;
     116    cairo_matrix_init_scale(&fontMatrix, size, size);
     117    cairo_matrix_t ctm;
     118    cairo_matrix_init_identity(&ctm);
     119    cairo_font_options_t* options = cairo_font_options_create();
     120
     121    // We force antialiasing and disable hinting to provide consistent
     122    // typographic qualities for custom fonts on all platforms.
     123    cairo_font_options_set_hint_style(options, CAIRO_HINT_STYLE_NONE);
     124    cairo_font_options_set_antialias(options, CAIRO_ANTIALIAS_GRAY);
     125
     126    m_scaledFont = cairo_scaled_font_create(fontFace, &fontMatrix, &ctm, options);
     127    cairo_font_options_destroy(options);
     128}
     129
    114130bool FontPlatformData::init()
    115131{
    116     static bool initialized;
     132    static bool initialized = false;
    117133    if (initialized)
    118134        return true;
    119     initialized = true;
    120135    if (!FcInit()) {
    121136        fprintf(stderr, "Can't init font config library\n");
    122137        return false;
    123138    }
     139    initialized = true;
    124140    return true;
    125141}
     
    131147bool FontPlatformData::isFixedPitch()
    132148{
     149    // TODO: Support isFixedPitch() for custom fonts.
     150    if (!m_pattern)
     151        return false;
     152
    133153    int spacing;
    134154    if (FcPatternGetInteger(m_pattern, FC_SPACING, 0, &spacing) == FcResultMatch)
  • trunk/WebCore/platform/graphics/gtk/SimpleFontDataGtk.cpp

    r29250 r29418  
    22 * Copyright (C) 2006 Apple Computer, Inc.  All rights reserved.
    33 * Copyright (C) 2006 Michael Emmel mike.emmel@gmail.com
    4  * Copyright (C) 2007 Alp Toker <alp.toker@collabora.co.uk>
     4 * Copyright (C) 2007, 2008 Alp Toker <alp@atoker.com>
    55 * Copyright (C) 2007 Holger Hans Peter Freyther
    66 * All rights reserved.
     
    6363void SimpleFontData::platformDestroy()
    6464{
    65     if (m_font.m_pattern && ((FcPattern*)-1 != m_font.m_pattern))
    66         FcPatternDestroy(m_font.m_pattern);
     65    if (!isCustomFont()) {
     66        if (m_font.m_pattern && ((FcPattern*)-1 != m_font.m_pattern)) {
     67            FcPatternDestroy(m_font.m_pattern);
     68            m_font.m_pattern = 0;
     69        }
    6770
    68     if (m_font.m_scaledFont)
    69         cairo_scaled_font_destroy(m_font.m_scaledFont);
     71        if (m_font.m_scaledFont) {
     72            cairo_scaled_font_destroy(m_font.m_scaledFont);
     73            m_font.m_scaledFont = 0;
     74        }
     75    }
     76
    7077    delete m_smallCapsFontData;
    7178}
Note: See TracChangeset for help on using the changeset viewer.