Changeset 96378 in webkit


Ignore:
Timestamp:
Sep 29, 2011 4:47:40 PM (13 years ago)
Author:
Martin Robinson
Message:

[Freetype] Some text in Planet GNOME renders in the wrong place
https://bugs.webkit.org/show_bug.cgi?id=69099

Reviewed by Dirk Schulze.

Source/WebCore:

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

Fold the oblique transform into the font matrix itself rather than transforming
the CTM of the context at render time. Not only does this fix the issue, it
prevents unnecessary work on every paint.

  • platform/graphics/cairo/FontCairo.cpp:

No longer set the synthetic oblique transformation matrix on the context
when rendering the text. Instead it is now folded into the TM of the font
itself.

  • platform/graphics/freetype/FontPlatformDataFreeType.cpp:

(WebCore::FontPlatformData::initializeWithFontFace): Fold the oblique transform into the scaled font.

  • platform/graphics/win/FontPlatformDataCairoWin.cpp:

(WebCore::FontPlatformData::FontPlatformData): Ditto.

LayoutTests:

Add a test which exercises this issue. It seems the problem grows worse
as the y component of the text position increases, so position the text
about halfway down the page.

  • platform/gtk/fonts/synthetic-oblique-positioning-expected.png: Added.
  • platform/gtk/fonts/synthetic-oblique-positioning-expected.txt: Added.
  • platform/gtk/fonts/synthetic-oblique-positioning.html: Added.
Location:
trunk
Files:
3 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r96376 r96378  
     12011-09-29  Martin Robinson  <mrobinson@igalia.com>
     2
     3        [Freetype] Some text in Planet GNOME renders in the wrong place
     4        https://bugs.webkit.org/show_bug.cgi?id=69099
     5
     6        Reviewed by Dirk Schulze.
     7
     8        Add a test which exercises this issue. It seems the problem grows worse
     9        as the y component of the text position increases, so position the text
     10        about halfway down the page.
     11
     12        * platform/gtk/fonts/synthetic-oblique-positioning-expected.png: Added.
     13        * platform/gtk/fonts/synthetic-oblique-positioning-expected.txt: Added.
     14        * platform/gtk/fonts/synthetic-oblique-positioning.html: Added.
     15
    1162011-09-29  Adam Barth  <abarth@webkit.org>
    217
  • trunk/Source/WebCore/ChangeLog

    r96374 r96378  
     12011-09-29  Martin Robinson  <mrobinson@igalia.com>
     2
     3        [Freetype] Some text in Planet GNOME renders in the wrong place
     4        https://bugs.webkit.org/show_bug.cgi?id=69099
     5
     6        Reviewed by Dirk Schulze.
     7
     8        Test: platform/gtk/fonts/synthetic-oblique-positioning.html
     9
     10        Fold the oblique transform into the font matrix itself rather than transforming
     11        the CTM of the context at render time. Not only does this fix the issue, it
     12        prevents unnecessary work on every paint.
     13
     14        * platform/graphics/cairo/FontCairo.cpp:
     15        No longer set the synthetic oblique transformation matrix on the context
     16        when rendering the text. Instead it is now folded into the TM of the font
     17        itself.
     18        * platform/graphics/freetype/FontPlatformDataFreeType.cpp:
     19        (WebCore::FontPlatformData::initializeWithFontFace): Fold the oblique transform into the scaled font.
     20        * platform/graphics/win/FontPlatformDataCairoWin.cpp:
     21        (WebCore::FontPlatformData::FontPlatformData): Ditto.
     22
    1232011-09-29  Dan Bernstein  <mitz@apple.com>
    224
  • trunk/Source/WebCore/platform/graphics/cairo/FontCairo.cpp

    r95901 r96378  
    4444namespace WebCore {
    4545
    46 static const float gSyntheticObliqueSkew = -tanf(14 * acosf(0) / 90);
    47 
    48 static void prepareContextForGlyphDrawing(cairo_t* context, const SimpleFontData* font)
    49 {
    50     cairo_set_scaled_font(context, font->platformData().scaledFont());
    51 
    52     if (font->platformData().syntheticOblique()) {
    53         cairo_matrix_t mat = {1, 0, gSyntheticObliqueSkew, 1, 0, 0};
    54         cairo_transform(context, &mat);
    55     }
    56 }
    57 
    5846static void drawGlyphsToContext(cairo_t* context, const SimpleFontData* font, GlyphBufferGlyph* glyphs, int numGlyphs)
    5947{
    6048    cairo_matrix_t originalTransform;
    6149    float syntheticBoldOffset = font->syntheticBoldOffset();
    62     if (font->platformData().syntheticOblique() || syntheticBoldOffset)
     50    if (syntheticBoldOffset)
    6351        cairo_get_matrix(context, &originalTransform);
    6452
    65     prepareContextForGlyphDrawing(context, font);
     53    cairo_set_scaled_font(context, font->platformData().scaledFont());
    6654    cairo_show_glyphs(context, glyphs, numGlyphs);
    6755
     
    7159    }
    7260
    73     if (font->platformData().syntheticOblique() || syntheticBoldOffset)
     61    if (syntheticBoldOffset)
    7462        cairo_set_matrix(context, &originalTransform);
    7563}
     
    140128
    141129        // This may disturb the CTM, but we are going to call cairo_restore soon after.
    142         prepareContextForGlyphDrawing(cr, font);
     130        cairo_set_scaled_font(cr, font->platformData().scaledFont());
    143131        cairo_glyph_path(cr, glyphs, numGlyphs);
    144132        cairo_stroke(cr);
  • trunk/Source/WebCore/platform/graphics/freetype/FontPlatformDataFreeType.cpp

    r90041 r96378  
    271271    }
    272272
     273    if (syntheticOblique()) {
     274        static const float syntheticObliqueSkew = -tanf(14 * acosf(0) / 90);
     275        cairo_matrix_t skew = {1, 0, syntheticObliqueSkew, 1, 0, 0};
     276        cairo_matrix_multiply(&fontMatrix, &skew, &fontMatrix);
     277    }
     278
    273279    m_scaledFont = cairo_scaled_font_create(fontFace, &fontMatrix, &ctm, options);
    274280    cairo_font_options_destroy(options);
  • trunk/Source/WebCore/platform/graphics/win/FontPlatformDataCairoWin.cpp

    r95901 r96378  
    8080   cairo_font_options_set_antialias(options, CAIRO_ANTIALIAS_GRAY);
    8181
     82    if (syntheticOblique()) {
     83        static const float syntheticObliqueSkew = -tanf(14 * acosf(0) / 90);
     84        cairo_matrix_t skew = {1, 0, syntheticObliqueSkew, 1, 0, 0};
     85        cairo_matrix_multiply(&fontMatrix, &skew, &fontMatrix);
     86    }
     87
    8288   m_scaledFont = cairo_scaled_font_create(fontFace, &fontMatrix, &ctm, options);
    8389   cairo_font_options_destroy(options);
Note: See TracChangeset for help on using the changeset viewer.