Skip to content

[css-text] Clarify how letter-spacing and word-spacing should affect tab-size. #643

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wisniewskit opened this issue Oct 25, 2016 · 5 comments
Labels
css-text-3 Current Work Tested Memory aid - issue has WPT tests Tracked in DoC

Comments

@wisniewskit
Copy link

Recently it was resolved that letter-spacing and word-spacing should affect tab-size, as per this proposal:

tab stops are calculated as
n*( width of U+0020 plus letter-spacing plus word-spacing)

But this seems strange to me, as tab characters are already affected by letter-spacing, aren't they? (That's what I'm seeing while playing around in devtools in Firefox and Chrome). Why count letter-spacing twice for tabs?

In addition, tabs aren't word-separators in the spec, which also states:

If there are no word-separator characters, or if a word-separating character has a zero advance width (such as the zero width space U+200B) then the user agent must not create an additional spacing between words.

How is this meant to be reconciled? Should the word-spacing be applied regardless of whether there are word-separator characters in the run?

@dbaron dbaron added the css-text-3 Current Work label Oct 25, 2016
@dbaron
Copy link
Member

dbaron commented Dec 22, 2016

A few thoughts here (basically crossposting from the Gecko bug):

  • Tabs currently get one letter-spacing already. So I think integer values of tab-size should account for letter-spacing by using the formula:
    N*(width of U+0020) + (N-1)*letter-spacing
  • I don't understand the motivation for accounting for word-spacing, so it's hard for me to tell what was intended. What is accounting for word-spacing supposed to make things line up with?

@dbaron dbaron added the Agenda+ label Dec 22, 2016
@fantasai
Copy link
Collaborator

fantasai commented Jan 3, 2017

Tabs are defined to be rendered as a shift in position, not as a grapheme affected by letter-spacing or word-spacing. https://drafts.csswg.org/css-text/#white-space-phase-2

Each tab is rendered as a horizontal shift that lines up the start edge of the next glyph with the next tab stop. Tab stops occur at points that are multiples of the tab size from the block’s starting content edge.

I can clarify in letter-spacing that tabs are not affected, if that is a point of confusion.

dbaron wrote:

I don't understand the motivation for accounting for word-spacing, so it's hard for me to tell what was intended. What is accounting for word-spacing supposed to make things line up with?

Spaces. Spaces are increased by word-spacing, so for tab stops to line up with multiples of spaces, they must account for the width of the space, plus letter-spacing, plus word-spacing.

@dbaron
Copy link
Member

dbaron commented Jan 3, 2017

Are there implementations that implement tabs in preformatted text in terms of that tab stop mechanism?

It's not clear to me how it's supposed to interact with changes of font, tab-size, letter-spacing, or word-spacing within a block. Are tab stops just always recomputed using the local properties, but then measured relative to the nearest block's content edge?

@fantasai
Copy link
Collaborator

fantasai commented Jan 4, 2017

tab-size is a property of the containing block. If this is a compat problem, that's a separate issue then.

@fantasai
Copy link
Collaborator

Closing the issue, please feel free to re-open if the spec remains unclear

(Wrt tab-size being applied to the containing block, if that's a problem, please file a separate issue on it.)

@frivoal frivoal added the Tested Memory aid - issue has WPT tests label Apr 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
css-text-3 Current Work Tested Memory aid - issue has WPT tests Tracked in DoC
Projects
None yet
Development

No branches or pull requests

4 participants