From: mrobinson@webkit.org Date: Thu, 29 Sep 2011 23:47:40 +0000 (+0000) Subject: [Freetype] Some text in Planet GNOME renders in the wrong place X-Git-Tag: 070512121124~23315 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=01220893e981a653d20b8c16c8dfc8b17e108a7d;p=profile%2Fivi%2Fwebkit-efl.git [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. git-svn-id: http://svn.webkit.org/repository/webkit/trunk@96378 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog index 2030f6e..8c82e87 100644 --- a/LayoutTests/ChangeLog +++ b/LayoutTests/ChangeLog @@ -1,3 +1,18 @@ +2011-09-29 Martin Robinson + + [Freetype] Some text in Planet GNOME renders in the wrong place + https://bugs.webkit.org/show_bug.cgi?id=69099 + + Reviewed by Dirk Schulze. + + 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. + 2011-09-29 Adam Barth Update image baselines after http://trac.webkit.org/changeset/96366. These are progressions. diff --git a/LayoutTests/platform/gtk/fonts/synthetic-oblique-positioning-expected.png b/LayoutTests/platform/gtk/fonts/synthetic-oblique-positioning-expected.png new file mode 100644 index 0000000..eaf4509 Binary files /dev/null and b/LayoutTests/platform/gtk/fonts/synthetic-oblique-positioning-expected.png differ diff --git a/LayoutTests/platform/gtk/fonts/synthetic-oblique-positioning-expected.txt b/LayoutTests/platform/gtk/fonts/synthetic-oblique-positioning-expected.txt new file mode 100644 index 0000000..2c1c1e3 --- /dev/null +++ b/LayoutTests/platform/gtk/fonts/synthetic-oblique-positioning-expected.txt @@ -0,0 +1,14 @@ +layer at (0,0) size 800x600 + RenderView at (0,0) size 800x600 +layer at (0,0) size 800x600 + RenderBlock {HTML} at (0,0) size 800x600 + RenderBody {BODY} at (8,8) size 784x584 +layer at (8,200) size 200x40 + RenderBlock (positioned) {DIV} at (8,200) size 200x40 + RenderText {#text} at (0,0) size 80x40 + text run at (0,0) width 80: "A " + RenderInline {CITE} at (0,0) size 40x40 + RenderText {#text} at (80,0) size 40x40 + text run at (80,0) width 40: "B" + RenderText {#text} at (120,0) size 80x40 + text run at (120,0) width 80: " C" diff --git a/LayoutTests/platform/gtk/fonts/synthetic-oblique-positioning.html b/LayoutTests/platform/gtk/fonts/synthetic-oblique-positioning.html new file mode 100644 index 0000000..d92ffde --- /dev/null +++ b/LayoutTests/platform/gtk/fonts/synthetic-oblique-positioning.html @@ -0,0 +1,31 @@ + + + + + + + + + + +
+A B C +
+ + diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog index 9ce8dd3..f651551 100644 --- a/Source/WebCore/ChangeLog +++ b/Source/WebCore/ChangeLog @@ -1,3 +1,25 @@ +2011-09-29 Martin Robinson + + [Freetype] Some text in Planet GNOME renders in the wrong place + https://bugs.webkit.org/show_bug.cgi?id=69099 + + Reviewed by Dirk Schulze. + + 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. + 2011-09-29 Dan Bernstein Follow-up fix for Glyph variants (line final swashes) appear where they should not diff --git a/Source/WebCore/platform/graphics/cairo/FontCairo.cpp b/Source/WebCore/platform/graphics/cairo/FontCairo.cpp index 5b4d0be..35d1e5b 100644 --- a/Source/WebCore/platform/graphics/cairo/FontCairo.cpp +++ b/Source/WebCore/platform/graphics/cairo/FontCairo.cpp @@ -43,26 +43,14 @@ namespace WebCore { -static const float gSyntheticObliqueSkew = -tanf(14 * acosf(0) / 90); - -static void prepareContextForGlyphDrawing(cairo_t* context, const SimpleFontData* font) -{ - cairo_set_scaled_font(context, font->platformData().scaledFont()); - - if (font->platformData().syntheticOblique()) { - cairo_matrix_t mat = {1, 0, gSyntheticObliqueSkew, 1, 0, 0}; - cairo_transform(context, &mat); - } -} - static void drawGlyphsToContext(cairo_t* context, const SimpleFontData* font, GlyphBufferGlyph* glyphs, int numGlyphs) { cairo_matrix_t originalTransform; float syntheticBoldOffset = font->syntheticBoldOffset(); - if (font->platformData().syntheticOblique() || syntheticBoldOffset) + if (syntheticBoldOffset) cairo_get_matrix(context, &originalTransform); - prepareContextForGlyphDrawing(context, font); + cairo_set_scaled_font(context, font->platformData().scaledFont()); cairo_show_glyphs(context, glyphs, numGlyphs); if (syntheticBoldOffset) { @@ -70,7 +58,7 @@ static void drawGlyphsToContext(cairo_t* context, const SimpleFontData* font, Gl cairo_show_glyphs(context, glyphs, numGlyphs); } - if (font->platformData().syntheticOblique() || syntheticBoldOffset) + if (syntheticBoldOffset) cairo_set_matrix(context, &originalTransform); } @@ -139,7 +127,7 @@ void Font::drawGlyphs(GraphicsContext* context, const SimpleFontData* font, cons cairo_set_line_width(cr, context->strokeThickness()); // This may disturb the CTM, but we are going to call cairo_restore soon after. - prepareContextForGlyphDrawing(cr, font); + cairo_set_scaled_font(cr, font->platformData().scaledFont()); cairo_glyph_path(cr, glyphs, numGlyphs); cairo_stroke(cr); } diff --git a/Source/WebCore/platform/graphics/freetype/FontPlatformDataFreeType.cpp b/Source/WebCore/platform/graphics/freetype/FontPlatformDataFreeType.cpp index 1ca5c9e..47b2f7e 100644 --- a/Source/WebCore/platform/graphics/freetype/FontPlatformDataFreeType.cpp +++ b/Source/WebCore/platform/graphics/freetype/FontPlatformDataFreeType.cpp @@ -270,6 +270,12 @@ void FontPlatformData::initializeWithFontFace(cairo_font_face_t* fontFace) cairo_matrix_scale(&fontMatrix, realSize, realSize); } + if (syntheticOblique()) { + static const float syntheticObliqueSkew = -tanf(14 * acosf(0) / 90); + cairo_matrix_t skew = {1, 0, syntheticObliqueSkew, 1, 0, 0}; + cairo_matrix_multiply(&fontMatrix, &skew, &fontMatrix); + } + m_scaledFont = cairo_scaled_font_create(fontFace, &fontMatrix, &ctm, options); cairo_font_options_destroy(options); } diff --git a/Source/WebCore/platform/graphics/win/FontPlatformDataCairoWin.cpp b/Source/WebCore/platform/graphics/win/FontPlatformDataCairoWin.cpp index e60b69b..82d6b4f 100644 --- a/Source/WebCore/platform/graphics/win/FontPlatformDataCairoWin.cpp +++ b/Source/WebCore/platform/graphics/win/FontPlatformDataCairoWin.cpp @@ -79,6 +79,12 @@ FontPlatformData::FontPlatformData(cairo_font_face_t* fontFace, float size, bool cairo_font_options_set_hint_style(options, CAIRO_HINT_STYLE_NONE); cairo_font_options_set_antialias(options, CAIRO_ANTIALIAS_GRAY); + if (syntheticOblique()) { + static const float syntheticObliqueSkew = -tanf(14 * acosf(0) / 90); + cairo_matrix_t skew = {1, 0, syntheticObliqueSkew, 1, 0, 0}; + cairo_matrix_multiply(&fontMatrix, &skew, &fontMatrix); + } + m_scaledFont = cairo_scaled_font_create(fontFace, &fontMatrix, &ctm, options); cairo_font_options_destroy(options); }