Changeset 69137 in webkit


Ignore:
Timestamp:
Oct 5, 2010 1:09:25 PM (14 years ago)
Author:
Martin Robinson
Message:

2010-10-05 Martin Robinson <mrobinson@igalia.com>

Reviewed by Xan Lopez.

[GTK] Support FontPlatformData::isFixedPitch for custom fonts
https://bugs.webkit.org/show_bug.cgi?id=47124

Instead of determining whether or not a font is a fixed-width font
lazily, do it up front. For fonts not backed by Fontconfig patterns,
fetch information about whether or not the font is fixed-width from
the FreeType face.

No new tests as this should not change functionality.

  • platform/graphics/cairo/FontPlatformDataFreeType.cpp: (WebCore::FontPlatformData::FontPlatformData): Initialize the m_fixedWidth member from the Fontconfig pattern or the FreeType face. (WebCore::FontPlatformData::operator=): Copy over the m_fixedWidth member. (WebCore::FontPlatformData::isFixedPitch): Just return the value of the m_fixedWidth member.
  • platform/graphics/cairo/FontPlatformDataFreeType.h: Added an m_fixedWidth member.
Location:
trunk/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r69136 r69137  
     12010-10-05  Martin Robinson  <mrobinson@igalia.com>
     2
     3        Reviewed by Xan Lopez.
     4
     5        [GTK] Support FontPlatformData::isFixedPitch for custom fonts
     6        https://bugs.webkit.org/show_bug.cgi?id=47124
     7
     8        Instead of determining whether or not a font is a fixed-width font
     9        lazily, do it up front. For fonts not backed by Fontconfig patterns,
     10        fetch information about whether or not the font is fixed-width from
     11        the FreeType face.
     12
     13        No new tests as this should not change functionality.
     14
     15        * platform/graphics/cairo/FontPlatformDataFreeType.cpp:
     16        (WebCore::FontPlatformData::FontPlatformData): Initialize the m_fixedWidth member
     17        from the Fontconfig pattern or the FreeType face.
     18        (WebCore::FontPlatformData::operator=): Copy over the m_fixedWidth member.
     19        (WebCore::FontPlatformData::isFixedPitch): Just return the value of the m_fixedWidth member.
     20        * platform/graphics/cairo/FontPlatformDataFreeType.h: Added an m_fixedWidth member.
     21
    1222010-10-05  David Hyatt  <hyatt@apple.com>
    223
  • trunk/WebCore/platform/graphics/cairo/FontPlatformDataFreeType.cpp

    r68558 r69137  
    9999    , m_syntheticBold(false)
    100100    , m_syntheticOblique(false)
     101    , m_fixedWidth(false)
    101102{
    102103    cairo_font_options_t* options = cairo_font_options_create();
     
    110111    PlatformRefPtr<cairo_font_face_t> fontFace = adoptPlatformRef(cairo_ft_font_face_create_for_pattern(m_pattern.get()));
    111112    m_scaledFont = adoptPlatformRef(cairo_scaled_font_create(fontFace.get(), &fontMatrix, &ctm, options));
     113
     114    int spacing;
     115    if (FcPatternGetInteger(pattern, FC_SPACING, 0, &spacing) == FcResultMatch && spacing == FC_MONO)
     116        m_fixedWidth = true;
    112117}
    113118
     
    117122    , m_syntheticBold(bold)
    118123    , m_syntheticOblique(italic)
     124    , m_fixedWidth(false)
    119125{
    120126}
     
    144150
    145151    m_scaledFont = adoptPlatformRef(cairo_scaled_font_create(fontFace, &fontMatrix, &ctm, options));
     152
     153    FT_Face fontConfigFace = cairo_ft_scaled_font_lock_face(m_scaledFont.get());
     154    if (fontConfigFace) {
     155        m_fixedWidth = fontConfigFace->face_flags && FT_FACE_FLAG_FIXED_WIDTH;
     156        cairo_ft_scaled_font_unlock_face(m_scaledFont.get());
     157    }
    146158}
    147159
     
    155167    m_syntheticBold = other.m_syntheticBold;
    156168    m_syntheticOblique = other.m_syntheticOblique;
     169    m_fixedWidth = other.m_fixedWidth;
    157170    m_scaledFont = other.m_scaledFont;
    158171    m_pattern = other.m_pattern;
     
    183196bool FontPlatformData::isFixedPitch()
    184197{
    185     // TODO: Support isFixedPitch() for custom fonts.
    186     if (!m_pattern)
    187         return false;
    188 
    189     int spacing;
    190     if (FcPatternGetInteger(m_pattern.get(), FC_SPACING, 0, &spacing) == FcResultMatch)
    191         return spacing == FC_MONO;
    192     return false;
     198    return m_fixedWidth;
    193199}
    194200
  • trunk/WebCore/platform/graphics/cairo/FontPlatformDataFreeType.h

    r68406 r69137  
    9090    bool m_syntheticBold;
    9191    bool m_syntheticOblique;
     92    bool m_fixedWidth;
    9293    PlatformRefPtr<cairo_scaled_font_t> m_scaledFont;
    9394};
Note: See TracChangeset for help on using the changeset viewer.