Open Bug 1134098 Opened 9 years ago Updated 2 years ago

negative letter-spacing causes 2+ tab characters to be drawn like 1 tab

Categories

(Core :: Layout: Text and Fonts, defect)

35 Branch
x86
macOS
defect

Tracking

()

UNCONFIRMED

People

(Reporter: mozbugzilla2021, Unassigned)

References

()

Details

(Keywords: testcase)

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:35.0) Gecko/20100101 Firefox/35.0
Build ID: 20150122214805

Steps to reproduce:

1. http://jsfiddle.net/wxhLqjmr/show


Actual results:

Line “B” and line “C” in <pre id="bad"> are indented the same amount


Expected results:

Line “C” in should be indented twice as much as line “B”, like in <pre id="good">
Safari 7:   OK
IE 11:      OK
Chrome 40:  bad
Firefox 35: bad
Component: Untriaged → Layout: Text
Keywords: testcase
Product: Firefox → Core
The problem is that you get letter spacing between the tabs, no?  So the second tab is starting before the first tab stop....
@bz Yes, I suppose each subsequent tab is backed up by 1px and then runs forward 1px to the first tab stop, over and over again. That makes sense, though it’s a quite surprising behaviour on the surface.

Having looked at the latest CSS Text draft, there’s nothing in the spec that really talks about what to do with negative values letter-spacing values except to say “Values may be negative, but there may be implementation-dependent limits” in §8.2. So, I guess the spec provides leeway to allow it to work this way (“implementation-dependent limit”), but as an author I would expect behaviour matching IE and Safari, where the tab stops are reduced by negative letter-spacing, so when you use tab characters, adjustments to letter-spacing don’t “break” them.

I found a similar recent ticket before making this one that was closed/blocked from comment <https://bugzilla.mozilla.org/show_bug.cgi?id=1124344>, that has an open thread on www-style to talk about the influence of letter-spacing on tabs. I don’t participate on the MLs (takes too much time for me) but I think this is another good point in favour of trying to clear up the spec.

Best,
Just reducing the tab stop positions per bug 1124344 won't necessarily help with this issue.  Consider this testcase:

<pre style="letter-spacing: -1px">
&#9;        x
&#9;&#9;x
</pre>

Should those two 'x' line up (note that in Safari they do not: the second one is further right than the first).  If they should (as bug 1124344 requests), then that means the second tab starts before the end of the first tab, just like the first of the 8 spaces starts before the end of the first tab....
(In reply to Boris Zbarsky [:bz] from comment #2)
> The problem is that you get letter spacing between the tabs, no?  So the
> second tab is starting before the first tab stop....

I expect that's what is happening, but this does seem like a bug to me. According to CSS Text, letter-spacing is supposed to apply between "characters" (used as a "friendlier synonym for grapheme cluster"), but I'm not at all sure <tab> qualifies as such; it's a control code, not a grapheme cluster at all.

So I would expect the sequence <tab, tab> to advance to the next-but-one tab position, regardless of any negative letter-spacing that may be in effect.
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.