RESOLVED FIXED 65035
[Cairo] Text extent of shadowed text is calculated incorrectly
https://bugs.webkit.org/show_bug.cgi?id=65035
Summary [Cairo] Text extent of shadowed text is calculated incorrectly
Martin Robinson
Reported 2011-07-22 11:10:59 PDT
This became apparently during conversion of Cairo shadows to using ShadowBlur. The failure is covered by LayoutTests/fast/canvas/fillText-shadow.html.
Attachments
use y_bearing instead of height to correctly get rect covering the shadow (961 bytes, patch)
2012-01-25 04:45 PST, Onne Gorter
no flags
Onne Gorter
Comment 1 2012-01-25 04:43:59 PST
I confirm and have a patch: --- a/Source/WebCore/platform/graphics/cairo/FontCairo.cpp +++ b/Source/WebCore/platform/graphics/cairo/FontCairo.cpp @@ -85,7 +85,7 @@ static void drawGlyphsShadow(GraphicsContext* graphicsContext, const FloatPoint& cairo_text_extents_t extents; cairo_scaled_font_glyph_extents(font->platformData().scaledFont(), glyphs, numGlyphs, &extents); - FloatRect fontExtentsRect(point.x(), point.y() - extents.height, extents.width, extents.height); + FloatRect fontExtentsRect(point.x(), point.y() + extents.y_bearing, extents.width, extents.height); if (GraphicsContext* shadowContext = shadow.beginShadowLayer(graphicsContext, fontExtentsRect)) { drawGlyphsToContext(shadowContext->platformContext()->cr(), font, glyphs, numGlyphs); shadow.endShadowLayer(graphicsContext);
Onne Gorter
Comment 2 2012-01-25 04:45:28 PST
Created attachment 123923 [details] use y_bearing instead of height to correctly get rect covering the shadow
Martin Robinson
Comment 3 2012-01-31 13:51:33 PST
Thanks for your contribution. Do you mind attaching a changelog as explained here? http://www.webkit.org/coding/contributing.html? If you do that I can commit your patch straight from this bug. Please just remove the line about missing tests and replace it with a statement that it's covered by the test I listed above.
Martin Robinson
Comment 4 2012-03-16 19:51:50 PDT
(In reply to comment #1) > I confirm and have a patch: > > --- a/Source/WebCore/platform/graphics/cairo/FontCairo.cpp > +++ b/Source/WebCore/platform/graphics/cairo/FontCairo.cpp > @@ -85,7 +85,7 @@ static void drawGlyphsShadow(GraphicsContext* graphicsContext, const FloatPoint& > > cairo_text_extents_t extents; > cairo_scaled_font_glyph_extents(font->platformData().scaledFont(), glyphs, numGlyphs, &extents); > - FloatRect fontExtentsRect(point.x(), point.y() - extents.height, extents.width, extents.height); > + FloatRect fontExtentsRect(point.x(), point.y() + extents.y_bearing, extents.width, extents.height); It seems that we also need to look at the x_bearing here as well. Will make this change and land this patch. Thanks for the contribution!
Martin Robinson
Comment 5 2012-03-16 19:54:56 PDT
Note You need to log in before you can comment on or make changes to this bug.