Changeset 69320 in webkit


Ignore:
Timestamp:
Oct 7, 2010 10:46:53 AM (13 years ago)
Author:
Martin Robinson
Message:

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

Reviewed by Chris Fleizach.

[Gtk] CSS font-style: italic behavior
https://bugs.webkit.org/show_bug.cgi?id=33299

Added a test to test the FontConfig synthetic oblique behavior.

  • platform/gtk/fonts/fontconfig-synthetic-oblique-expected.checksum: Added.
  • platform/gtk/fonts/fontconfig-synthetic-oblique-expected.png: Added.
  • platform/gtk/fonts/fontconfig-synthetic-oblique-expected.txt: Added.
  • platform/gtk/fonts/fontconfig-synthetic-oblique.html: Added.

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

Reviewed by Chris Fleizach.

[Gtk] CSS font-style: italic behavior
https://bugs.webkit.org/show_bug.cgi?id=33299

Properly interpret the FC_MATRIX property from a FontConfig pattern.
FontConfig will use this property when returning fonts which have a
synthetic oblique variant configured in the fonts.conf configuration
file.

Test: platform/gtk/fonts/fontconfig-synthetic-oblique.html

  • platform/graphics/cairo/FontPlatformDataFreeType.cpp: (WebCore::FontPlatformData::FontPlatformData): Added a constructor that takes an existing FontPlatformData and a font size. (WebCore::FontPlatformData::initializeWithFontFace): Added this helper intialization method that properly handles the FC_MATRIX property from the FcPattern.
  • platform/graphics/cairo/FontPlatformDataFreeType.h: Added a declaration to the new constructor and the initializeWithFontFace.
  • platform/graphics/cairo/SimpleFontDataCairo.cpp: (WebCore::SimpleFontData::smallCapsFontData): Use the new FontPlatformData constructor.
Location:
trunk
Files:
4 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r69314 r69320  
     12010-10-05  Martin Robinson  <mrobinson@igalia.com>
     2
     3        Reviewed by Chris Fleizach.
     4
     5        [Gtk] CSS font-style: italic behavior
     6        https://bugs.webkit.org/show_bug.cgi?id=33299
     7
     8        Added a test to test the FontConfig synthetic oblique behavior.
     9
     10        * platform/gtk/fonts/fontconfig-synthetic-oblique-expected.checksum: Added.
     11        * platform/gtk/fonts/fontconfig-synthetic-oblique-expected.png: Added.
     12        * platform/gtk/fonts/fontconfig-synthetic-oblique-expected.txt: Added.
     13        * platform/gtk/fonts/fontconfig-synthetic-oblique.html: Added.
     14
    1152010-10-07  Albert J. Wong  <ajwong@chromium.org>
    216
  • trunk/WebCore/ChangeLog

    r69319 r69320  
     12010-10-05  Martin Robinson  <mrobinson@igalia.com>
     2
     3        Reviewed by Chris Fleizach.
     4
     5        [Gtk] CSS font-style: italic behavior
     6        https://bugs.webkit.org/show_bug.cgi?id=33299
     7
     8        Properly interpret the FC_MATRIX property from a FontConfig pattern.
     9        FontConfig will use this property when returning fonts which have a
     10        synthetic oblique variant configured in the fonts.conf configuration
     11        file.
     12
     13        Test: platform/gtk/fonts/fontconfig-synthetic-oblique.html
     14
     15        * platform/graphics/cairo/FontPlatformDataFreeType.cpp:
     16        (WebCore::FontPlatformData::FontPlatformData): Added a constructor that
     17        takes an existing FontPlatformData and a font size.
     18        (WebCore::FontPlatformData::initializeWithFontFace): Added this helper
     19        intialization method that properly handles the FC_MATRIX property from
     20        the FcPattern.
     21        * platform/graphics/cairo/FontPlatformDataFreeType.h: Added a declaration
     22        to the new constructor and the initializeWithFontFace.
     23        * platform/graphics/cairo/SimpleFontDataCairo.cpp:
     24        (WebCore::SimpleFontData::smallCapsFontData): Use the new FontPlatformData
     25        constructor.
     26
    1272010-10-07  David Hyatt  <hyatt@apple.com>
    228
  • trunk/WebCore/platform/graphics/cairo/FontPlatformDataFreeType.cpp

    r69137 r69320  
    101101    , m_fixedWidth(false)
    102102{
    103     cairo_font_options_t* options = cairo_font_options_create();
    104     setCairoFontOptionsFromFontConfigPattern(options, pattern);
    105 
    106     cairo_matrix_t fontMatrix;
    107     cairo_matrix_init_scale(&fontMatrix, m_size, m_size);
    108     cairo_matrix_t ctm;
    109     cairo_matrix_init_identity(&ctm);
    110 
    111103    PlatformRefPtr<cairo_font_face_t> fontFace = adoptPlatformRef(cairo_ft_font_face_create_for_pattern(m_pattern.get()));
    112     m_scaledFont = adoptPlatformRef(cairo_scaled_font_create(fontFace.get(), &fontMatrix, &ctm, options));
     104    initializeWithFontFace(fontFace.get());
    113105
    114106    int spacing;
     
    124116    , m_fixedWidth(false)
    125117{
     118    // We cannot create a scaled font here.
    126119}
    127120
     
    132125    , m_syntheticOblique(italic)
    133126{
    134     cairo_matrix_t fontMatrix;
    135     cairo_matrix_init_scale(&fontMatrix, size, size);
    136     cairo_matrix_t ctm;
    137     cairo_matrix_init_identity(&ctm);
    138     static const cairo_font_options_t* defaultOptions = cairo_font_options_create();
    139     const cairo_font_options_t* options = NULL;
    140 
    141 #if !PLATFORM(EFL) || ENABLE(GLIB_SUPPORT)
    142     if (GdkScreen* screen = gdk_screen_get_default())
    143         options = gdk_screen_get_font_options(screen);
    144 #endif
    145 
    146     // gdk_screen_get_font_options() returns NULL if no default options are
    147     // set, so we always have to check.
    148     if (!options)
    149         options = defaultOptions;
    150 
    151     m_scaledFont = adoptPlatformRef(cairo_scaled_font_create(fontFace, &fontMatrix, &ctm, options));
     127    initializeWithFontFace(fontFace);
    152128
    153129    FT_Face fontConfigFace = cairo_ft_scaled_font_lock_face(m_scaledFont.get());
     
    186162}
    187163
     164FontPlatformData::FontPlatformData(const FontPlatformData& other, float size)
     165{
     166    *this = other;
     167
     168    // We need to reinitialize the instance, because the difference in size
     169    // necessitates a new scaled font instance.
     170    m_size = size;
     171    initializeWithFontFace(cairo_scaled_font_get_font_face(m_scaledFont.get()));
     172}
     173
    188174FontPlatformData::~FontPlatformData()
    189175{
     
    215201#endif
    216202
    217 }
     203void FontPlatformData::initializeWithFontFace(cairo_font_face_t* fontFace)
     204{
     205    cairo_font_options_t* options = 0;
     206#if !PLATFORM(EFL) || ENABLE(GLIB_SUPPORT)
     207    if (GdkScreen* screen = gdk_screen_get_default())
     208        options = cairo_font_options_copy(gdk_screen_get_font_options(screen));
     209#endif
     210    // gdk_screen_get_font_options() returns null if no default
     211    // options are set, so we always have to check.
     212    if (!options)
     213        options = cairo_font_options_create();
     214
     215    cairo_matrix_t ctm;
     216    cairo_matrix_init_identity(&ctm);
     217
     218    cairo_matrix_t fontMatrix;
     219    if (!m_pattern)
     220        cairo_matrix_init_scale(&fontMatrix, m_size, m_size);
     221    else {
     222        setCairoFontOptionsFromFontConfigPattern(options, m_pattern.get());
     223
     224        // FontConfig may return a list of transformation matrices with the pattern, for instance,
     225        // for fonts that are oblique. We use that to initialize the cairo font matrix.
     226        FcMatrix fontConfigMatrix, *tempFontConfigMatrix;
     227        FcMatrixInit(&fontConfigMatrix);
     228
     229        // These matrices may be stacked in the pattern, so it's our job to get them all and multiply them.
     230        for (int i = 0; FcPatternGetMatrix(m_pattern.get(), FC_MATRIX, i, &tempFontConfigMatrix) == FcResultMatch; i++)
     231            FcMatrixMultiply(&fontConfigMatrix, &fontConfigMatrix, tempFontConfigMatrix);
     232        cairo_matrix_init(&fontMatrix, fontConfigMatrix.xx, -fontConfigMatrix.yx,
     233                          -fontConfigMatrix.xy, fontConfigMatrix.yy, 0, 0);
     234
     235        // The matrix from FontConfig does not include the scale.
     236        cairo_matrix_scale(&fontMatrix, m_size, m_size);
     237    }
     238
     239    m_scaledFont = adoptPlatformRef(cairo_scaled_font_create(fontFace, &fontMatrix, &ctm, options));
     240    cairo_font_options_destroy(options);
     241}
     242
     243
     244}
  • trunk/WebCore/platform/graphics/cairo/FontPlatformDataFreeType.h

    r69137 r69320  
    5858    FontPlatformData(float size, bool bold, bool italic);
    5959    FontPlatformData(const FontPlatformData&);
     60    FontPlatformData(const FontPlatformData&, float size);
    6061
    6162    ~FontPlatformData();
     
    9293    bool m_fixedWidth;
    9394    PlatformRefPtr<cairo_scaled_font_t> m_scaledFont;
     95
     96private:
     97    void initializeWithFontFace(cairo_font_face_t*);
    9498};
    9599
Note: See TracChangeset for help on using the changeset viewer.