Bug 59589

Summary: REGRESSION(r77282-r77559): Scaled SVG text should pixel-align pre-scale
Product: WebKit Reporter: Alan Tam <Tam@SiuLung.com>
Component: SVGAssignee: Nobody <webkit-unassigned@lists.webkit.org>
Status: UNCONFIRMED    
Severity: Normal CC: cmarrin@apple.com, dino@apple.com, eoconnor@apple.com, krit@webkit.org, simon.fraser@apple.com, zimmermann@kde.org
Priority: P2 Keywords: InRadar
Version: 528+ (Nightly build)   
Hardware: Macintosh   
OS: Mac OS X 10.6   
Attachments:
Description Flags
test case
none
updated test case with mozilla and opera support
none
test results on Snow Leopard none

Description From 2011-04-27 02:15:23 PST
Created an attachment (id=91256) [details]
test case

See the attached test case.

<svg:g transform="scale(0.01)">
    <svg:text x="0" y="2000" style="font-size: 1100px; font-family: Georgia;">
        iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
    </svg:text>
 </svg:g>

The code above should draw "i" glyphs pixel aligned when they are 1100px large and then scaled down to 1/100 of its size.
WebKit r77559 later draw them pixel-aligned as if they are 11px large (i.e. after scaled down 1/100).
------- Comment #1 From 2011-04-27 05:46:08 PST -------
(In reply to comment #0)
> Created an attachment (id=91256) [details] [details]
> test case
> 
> See the attached test case.
> 
> <svg:g transform="scale(0.01)">
>     <svg:text x="0" y="2000" style="font-size: 1100px; font-family: Georgia;">
>         iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
>     </svg:text>
>  </svg:g>
> 
> The code above should draw "i" glyphs pixel aligned when they are 1100px large and then scaled down to 1/100 of its size.
> WebKit r77559 later draw them pixel-aligned as if they are 11px large (i.e. after scaled down 1/100).

Scale is like zooming, this of course influences the kerning as well. If I understand you right, you want to have the distances between the letters independent of the scaling? Nevertheless, the current behavior is exactly how it should look like and is the same like in Opera and Firefox. I'd like to mark this bug as invalid.

Btw. The example doesn't differ between Safari 5 and WebKit trunk.
------- Comment #2 From 2011-04-27 06:24:48 PST -------
Can you please upload a new test and add -o-transform and -moz-transform so that we can compare the results with the behavior o other browsers? Maybe it's a bug in -webkit-transform, or the specification of scale is different between CSS and SVG.

Added some CSS transform experts to the bug. Maybe they can look at the example as well.
------- Comment #3 From 2011-04-27 22:19:48 PST -------
Created an attachment (id=91428) [details]
updated test case with mozilla and opera support
------- Comment #4 From 2011-04-27 22:21:20 PST -------
Created an attachment (id=91429) [details]
test results on Snow Leopard
------- Comment #5 From 2011-04-27 22:45:03 PST -------
Hi Dirk,

Please refer to the attached screenshot of my test results for the discussion below.

It is not a kerning issue, but whether to align every glyph of the font onto the pixel grid. Note from the test results (test case 3) that all 4 browsers except Firefox does attempt to align every glyph to the pixel grid. Hence, every "i" is rendered in the same color (colored due to subpixel-antialiasing). Personally I don't care which way the browsers renders.

For HTML with scaling (test case 2), I expect browsers, even if they align to pixel grid, aligns to the grid that is 100x larger (i.e. when the font is 1100px large). Hence, every "i" is rendered in different color. All browsers seem to agree with this.

Test results (test case 1) with all browsers except WebKit trunk are same as what I expected, which is the same as rendering HTML unscaled.

I don't care whether to revert to Safari 5's behavior or follow Firefox 4's, but I believe the current one in WebKit trunk is a bug. In fact no browser agree with current WebKit trunk's behavior.
------- Comment #6 From 2011-05-04 19:20:13 PST -------
Alan, to clarify you're asking that the rendering revert to the previous behaviour, which is that the "i"s are different colours? And that would then match the HTML rendering (which has not changed)?

I don't think this has much to do with CSS transforms.
------- Comment #7 From 2011-05-04 20:19:05 PST -------
(In reply to comment #6)
> Alan, to clarify you're asking that the rendering revert to the previous behaviour, which is that the "i"s are different colours? And that would then match the HTML rendering (which has not changed)?

Yes, except "match the HTML rendering" should mean "match the HTML rendering of Firefox". Somehow Safari chooses to render all HTML text by aligning all glyphs to pixel grid (3rd row of 1st and 2nd columns in the screenshot). I don't know the reason (faster rendering?) but I believe it is irreverent to this discussion.


> I don't think this has much to do with CSS transforms.

Right, except for the caveat above. "Safari's HTML rendering" cannot be used to demonstrate expected behavior since it simply the unexpected behavior that I am complaining about. "Safari's HTML rendering with CSS transform" is what I want, so I simply used it to demonstrated what I expected to happen. You can safely ignore it given now we have the screenshot.
------- Comment #8 From 2011-05-06 16:08:07 PST -------
<rdar://problem/9357575>
------- Comment #9 From 2012-02-16 05:02:50 PST -------
Alan, I'm not 100% sure what you're actually asking for, can you re-explain?
I've compared WebKit trunk with Opera, and we render it exactly identical.