Closed
Bug 581092
Opened 15 years ago
Closed 15 years ago
[dwrite] REFTEST TEST-UNEXPECTED-FAIL | canvas/text-bidi-(ltr|rtl)-test.html |
Categories
(Core :: Graphics, defect)
Tracking
()
RESOLVED
FIXED
Tracking | Status | |
---|---|---|
blocking2.0 | --- | beta4+ |
People
(Reporter: jrmuizel, Assigned: jfkthame)
References
Details
Attachments
(2 files)
1010 bytes,
application/zip
|
Details | |
3.01 KB,
patch
|
vlad
:
review+
|
Details | Diff | Splinter Review |
No description provided.
(Since those other D2D-reftest bugs all had Win7 file URIs in the testnames, I assume the correct platform for these two is also Win7.)
OS: Mac OS X → Windows 7
Updated•15 years ago
|
Assignee: nobody → jfkthame
Assignee | ||
Comment 2•15 years ago
|
||
The reftest failure here occurs because the canvas bidi code rounds the width of text segments to whole pixels, but with directwrite enabled, text run widths and glyph positions may be fractional.
The attached testcase illustrates the problem; there are two versions of "hello world" drawn to a canvas element, one as LTR and the other as RTL. Flipping between them in tabs, a half-pixel difference in positioning can clearly be seen.
Checking values in nsCanvasBidiProcessor::GetWidth(), we see that with GDI, the textRun's mAdvanceWidth is 5640 appunits, which is exactly 94 pixels; thus, the appunits-to-integer device pixels conversion at http://mxr.mozilla.org/mozilla-central/source/content/canvas/src/nsCanvasRenderingContext2D.cpp#2594 is precise, and the drawing of the right-to-left run is as expected.
With DWrite enabled, the textRun returns an advance width of 5731 appunits, which represents 95.516667 device pixels. But nsCanvasBidiProcessor::GetWidth() returns this as a truncated value of 95, and therefore when the run is drawn from right to left, it appears approximately half a pixel to the left of its LTR position.
To fix this, I think we should probably modify the canvas bidi code to use fractional pixel values for textrun widths and positions throughout the line layout process. An alternative might be to paint RTL text runs by reversing the glyphs and then painting in LTR order, so that the rounding to integer device pixels is consistently happening at the left end of text runs.
Comment 3•15 years ago
|
||
Sounds like we need a modest change to canvas.
Assignee | ||
Comment 4•15 years ago
|
||
It turns out that OS X suffers from this exact same problem, as Quartz also does subpixel text positioning, and these two reftests are currently marked as failing on OS X. The fix should resolve the test failure for both platforms.
Assignee | ||
Comment 5•15 years ago
|
||
This seems to be the least-intrusive way to resolve the reftest failure on both OS X and Windows with DWrite.
We might want to consider using true subpixel metrics throughout the text layout process, but that would require a much more extensive patch and might have wider implications for canvas; I think if we want to look into that, we should treat it as a separate enhancement.
Assignee | ||
Updated•15 years ago
|
Attachment #462154 -
Flags: review?(vladimir)
Attachment #462154 -
Flags: review?(vladimir) → review+
Assignee | ||
Comment 6•15 years ago
|
||
Comment on attachment 462154 [details] [diff] [review]
patch, v1 - use non-rounded width when advancing to draw RTL glyph run
Requesting approval to land on trunk as we need this to pass reftests on Windows-D2D. (It also fixes a current known-failure on OS X.) The patch seems pretty safe as the change is extremely local in its effect.
Attachment #462154 -
Flags: approval2.0?
Comment 7•15 years ago
|
||
Heck, this blocks if we need it for reftests on D2D.
blocking2.0: --- → beta4+
Updated•15 years ago
|
Attachment #462154 -
Flags: approval2.0?
Assignee | ||
Comment 8•15 years ago
|
||
Status: NEW → RESOLVED
Closed: 15 years ago
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•