Last Comment Bug 675383 - DWrite font using GDI rendering mode has erratic spacing when a transform (e.g. synthetic italics) is in effect
: DWrite font using GDI rendering mode has erratic spacing when a transform (e....
Status: VERIFIED FIXED
: regression, testcase
Product: Core
Classification: Components
Component: Graphics (show other bugs)
: Trunk
: All Windows 7
: -- normal (vote)
: mozilla9
Assigned To: Jonathan Kew (:jfkthame)
:
:
Mentors:
Depends on:
Blocks: 661471
  Show dependency treegraph
 
Reported: 2011-07-29 17:20 PDT by Joe Wilson
Modified: 2011-09-23 01:00 PDT (History)
13 users (show)
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---
+
wontfix
+
fixed


Attachments
Ugly italic font (18.27 KB, image/png)
2011-07-29 17:20 PDT, Joe Wilson
no flags Details
Comparison (52.22 KB, image/png)
2011-07-29 17:27 PDT, Joe Wilson
no flags Details
reduced html (814 bytes, text/html)
2011-07-29 23:32 PDT, Alice0775 White
no flags Details
screen shot (38.76 KB, image/png)
2011-07-29 23:39 PDT, Alice0775 White
no flags Details
additional simplified testcase (3.39 KB, text/html)
2011-08-30 05:25 PDT, Jonathan Kew (:jfkthame)
no flags Details
screenshot of the preceding testcase (105.74 KB, image/png)
2011-08-30 05:27 PDT, Jonathan Kew (:jfkthame)
no flags Details
patch, v1 - add a tiny delta to glyph x-coordinates to ensure consistent rounding to whole pixels (2.95 KB, patch)
2011-08-30 05:45 PDT, Jonathan Kew (:jfkthame)
bas: review+
bugzilla: approval‑mozilla‑aurora+
christian: approval‑mozilla‑beta-
Details | Diff | Splinter Review
screenshot of testcase using patched build, showing consistent glyph positioning (109.55 KB, image/png)
2011-08-30 05:49 PDT, Jonathan Kew (:jfkthame)
no flags Details

Description Joe Wilson 2011-07-29 17:20:45 PDT
Created attachment 549524 [details]
Ugly italic font

1. Visit this page: http://forums.miranda-im.org/showthread.php?713-ICQ-Protocol-Discussion/page225
2. Focus your attention on the italic text in quoted messages.
3. Scroll the page up/down
4. Go to 2.

This is what I get (watch the attached screenshot).

If I select and de-select this text - it gets redrawn properly, until I scroll up/down again.

Latest Nightly.

Adapter Description NVIDIA GeForce GTX 560
Vendor ID 10de
Device ID 1201
Adapter RAM 1024
Adapter Drivers nvd3dumx,nvwgf2umx,nvwgf2umx nvd3dum,nvwgf2um,nvwgf2um
Driver Version 8.17.12.7533
Driver Date 5-20-2011
Direct2D Enabled true
DirectWrite Enabled true (6.1.7601.17563)
ClearType Parameters ClearType parameters not found
WebGL RendererGoogle Inc. -- ANGLE -- OpenGL ES 2.0 (ANGLE 0.0.0.686)
GPU Accelerated Windows1/1 Direct3D 10
Comment 1 Joe Wilson 2011-07-29 17:27:50 PDT
Created attachment 549526 [details]
Comparison

The comparison.
At the bottom is the same message, but after selecting and de-selecting the text.
Comment 2 Alice0775 White 2011-07-29 23:32:32 PDT
Created attachment 549551 [details]
reduced html
Comment 3 Alice0775 White 2011-07-29 23:39:21 PDT
Created attachment 549552 [details]
screen shot

Letter spacing is drawn at random.
And when I select text, the latter spacing is slightly changed.
Comment 4 Alice0775 White 2011-07-29 23:54:39 PDT
Regression window(cached m-c hourly:
Works:
http://hg.mozilla.org/mozilla-central/rev/09aa6c7e5867
Mozilla/5.0 (Windows NT 6.1; WOW64; rv:7.0a1) Gecko/20110602 Firefox/7.0a1 ID:20110602165615
Fails:
http://hg.mozilla.org/mozilla-central/rev/8a133638f5b6
Mozilla/5.0 (Windows NT 6.1; WOW64; rv:7.0a1) Gecko/20110602 Firefox/7.0a1 ID:20110602225429
Pushlog:
http://hg.mozilla.org/mozilla-central/pushloghtml?fromchange=09aa6c7e5867&tochange=8a133638f5b6

Suspected bug:
Bug 661471 - Create preference(s) to allow specific font families to be forced to use GDI Classic rendering
Comment 5 Alice0775 White 2011-07-30 08:56:47 PDT
In additio to the above,
When change browser width, the letter is dancing.
Comment 6 Jonathan Kew (:jfkthame) 2011-08-23 10:27:12 PDT
This appears to happen only when
(a) the font is being rendered via D2D/DWrite using GDI Classic mode, and
(b) there is no real italic/oblique face, so synthetic oblique is being used.
Comment 7 Jonathan Kew (:jfkthame) 2011-08-30 05:25:53 PDT
Created attachment 556805 [details]
additional simplified testcase

This testcase makes the erratic spacing really obvious in Tahoma with font-style:italic.

It also demonstrates that the same problem can occur in non-italic text when other transforms are used; the root of the problem lies in the presence of a transform. Use of italic style with a font that doesn't have a true italic or oblique face just happens to be the likeliest way to trigger the use of a transform on the text.

Note that scrolling the testcase vertically, even by just a single pixel, and then reloading will cause the erratic spacing in the italicized Tahoma to shift around. It also shifts during drag-selecting through the text, as different sub-runs get repainted.
Comment 8 Jonathan Kew (:jfkthame) 2011-08-30 05:27:40 PDT
Created attachment 556806 [details]
screenshot of the preceding testcase
Comment 9 Jonathan Kew (:jfkthame) 2011-08-30 05:45:22 PDT
Created attachment 556810 [details] [diff] [review]
patch, v1 - add a tiny delta to glyph x-coordinates to ensure consistent rounding to whole pixels

The problem arises when glyph positions fall exactly on half pixels, and then end up rounding erratically to whole-pixel positions after the transform-and-inverse-transform calculations introduce small floating-point errors. So the idea here is to add a small offset - tiny enough to be insignificant in comparison to appUnit coordinates - so that we nudge the values just enough that they're likely to round consistently even after the transforms.

I suppose it's possible that under "extreme" transformations, the error introduced by the matrix operations might still be enough to cause problems, but I think this should resolve the problem for any reasonable use-case.
Comment 10 Jonathan Kew (:jfkthame) 2011-08-30 05:49:26 PDT
Created attachment 556811 [details]
screenshot of testcase using patched build, showing consistent glyph positioning
Comment 11 Bas Schouten (:bas.schouten) 2011-08-30 07:42:14 PDT
Comment on attachment 556810 [details] [diff] [review]
patch, v1 - add a tiny delta to glyph x-coordinates to ensure consistent rounding to whole pixels

Review of attachment 556810 [details] [diff] [review]:
-----------------------------------------------------------------

Seems like a decent pragmatic solution to me!
Comment 13 Marco Bonardo [::mak] 2011-08-31 02:07:17 PDT
http://hg.mozilla.org/mozilla-central/rev/f1dbc0a63703
Comment 14 Vlad [QA] 2011-09-09 07:51:49 PDT
Setting resolution to Verified Fixed on Mozilla/5.0 (Windows NT 6.1; rv:9.0a1) Gecko/20110908 Firefox/9.0a1

I have used the simplified additional test case in order to verify this and now it works fine.

I have one question: why is this bug flagged tracking-firefox7 if it's target milestone is firefox 9?
Thanks
Comment 15 christian 2011-09-15 14:56:45 PDT
We flagged it was caused by a fix that made it in Firefox 7 and would likely appear to be a regression to users.
Comment 16 Jonathan Kew (:jfkthame) 2011-09-15 15:33:33 PDT
Comment on attachment 556810 [details] [diff] [review]
patch, v1 - add a tiny delta to glyph x-coordinates to ensure consistent rounding to whole pixels

Nominating for Aurora and Beta, as the regression will be visible to Windows users in common styles such as Tahoma italic, and the patch is extremely low risk - it just perturbs glyph positions by a tiny amount when drawing, in order to give predictable rounding behavior for positions that would otherwise be unstable under the effects of floating-point precision limits. There is no wider effect on layout, so I don't think there is any risk of breakage elsewhere due to this fix.
Comment 17 christian 2011-09-19 14:20:56 PDT
We haven't seen any user complaints and the problem seems to be superficial in an edge-case scenario. We're denying for beta as we are late in the game.
Comment 18 Johnathan Nightingale [:johnath] 2011-09-22 14:36:08 PDT
Comment on attachment 556810 [details] [diff] [review]
patch, v1 - add a tiny delta to glyph x-coordinates to ensure consistent rounding to whole pixels

Land it quickly, please!
Comment 19 Jonathan Kew (:jfkthame) 2011-09-23 01:00:42 PDT
https://hg.mozilla.org/releases/mozilla-aurora/rev/223f39756a26

Note You need to log in before you can comment on or make changes to this bug.