spacing text overflows from text frame (letter-spacing, text-align: justify;)

RESOLVED FIXED

Status

()

Core
Graphics
RESOLVED FIXED
11 years ago
11 years ago

People

(Reporter: masayuki, Assigned: roc)

Tracking

Trunk
x86
Linux
Points:
---
Dependency tree / graph
Bug Flags:
in-testsuite ?

Firefox Tracking Flags

(Not tracked)

Details

spinning off from bug 333659.

The spacing rendering has rounding problem to the dev pixels.
I'll attach the patch.
Summary: spacing text redering is broken (letter-spacing, text-align: justify;) → spacing text rendering is broken (letter-spacing, text-align: justify;)
I have two plans for this.

1. The actual values of letter-spacing and word-spacing should be rounded to the device pixels. We should add methods to nsStyleText for getting the rounded values. (Because we must keep the original values for computing values.) This change will change the behavior of letter-spacing. But I believe that the new behavior is more beautiful and better.

E.g., if the text has letter-spacing: 0.5px
current rendering: A[0px]B[1px]C[0px]D[1px]
new rendering:     A[1px]B[1px]C[1px]D[1px]

I think that the letter-spacings are should use same actual values in all points.

2. For justification, we should rounding the values in early time. I'm still thinking for finding the best point.
fantasai:

How do you think the rounding problem for letter-spacing?
# See 1. of comment 1.
I think that we should insert the same spaces between all characters. And we should insert 1 device pixels if the computed value is not zero and is less than 1 device pixel. I.e., even if it is less than 0.49 device pixels. Otherwise, we should round to nearest device pixels.
I do not think we should round letter-spacing and word-spacing to device pixels.  (Can't some font renderers even display glyphs at sub-pixel alignment?)
By the rounding problem, the letter-spacing rendering is broken. (The cause is bug 333659.) Before bug 333659, we rounded the spacing width in gfx.
# See https://bugzilla.mozilla.org/attachment.cgi?id=225991&action=diff
You can see the regression in:
https://bugzilla.mozilla.org/attachment.cgi?id=225152

When you select the text, the characters are shaken.
That "shaking" bug will probably be fixed with the new text frame.

dbaron: some font renderers can align glyphs with subpixel precision, but nothing we have access to yet, AFAIK. Of course we do want to support that when it emerges without more rearchitecture.
(In reply to comment #6)
> That "shaking" bug will probably be fixed with the new text frame.

Ah, I see. Because all glyph positions are always calculated from same string (so, it's never calculated from substring) in new text frame, right?
Yes, exactly.
Ah... Note that WinIE7 and Opera9 drop the decimal for letter-spacing and word-spacing. It may be good thing that we implement same behavior for compatibility... (Instead of rounding to nearest device pixels.)
(Reporter)

Updated

11 years ago
Depends on: 368107
I separated the issue for comment 9. See bug 368107. Because the shaking problem by letter-spacing/word-spacing are fixed by new text frame. (comment 6 and comment 7)
I can reproduce the glyphs overflowing from nsTextFrame only on Linux. (Win has only shaking problem.) I change the platform.
OS: All → Linux
Hardware: All → PC
Summary: spacing text rendering is broken (letter-spacing, text-align: justify;) → spacing text overflows from text frame (letter-spacing, text-align: justify;)
This is fixed by the patch in bug 370588.
Depends on: 370588
(In reply to comment #12)
> This is fixed by the patch in bug 370588.

I confirmed it, thank you, roc!
Assignee: masayuki → roc
OK.  That does not seem to resolve the shaking issue from comment #5.  Is there a separate bug for that?
bug 370588 was landed, the overflow problem was fixed.
Status: NEW → RESOLVED
Last Resolved: 11 years ago
Resolution: --- → FIXED
Flags: in-testsuite?
You need to log in before you can comment on or make changes to this bug.