Re: [csswg-drafts] [css-text] text-spacing is very complicated (#4246)

OK, so @florian and I did some brainstorming, and here's a simplified version of `text-spacing` and possible longhand expansion that tries to address the comments in #8288 #7183 #4246 #8263

Summary:
```
text-spacing: normal | none | auto | <'text-autospace'> || <'text-spacing-trim'>
  text-spacing-trim: auto | space-all |  trim-all | [ allow-end || space-first ]
  text-autospace: normal | auto | no-autospace |
                  [ ideograph-alpha || ideograph-numeric || punctuation ]
                  || [ insert | replace ]
```

**Fullwidth Punctuation Trimming**

```
text-spacing-trim (or text-spacing-full-width):
    auto | space-all |  trim-all | [ allow-end || space-first ]
```

This controls the spacing or trimming of fullwidth punctuations at the start, end, and adjacent positions. `[ allow-end || space-first]` are variations on `trim-all`. We don't think that there's a real need for these two values in combination with `space-all`, or with any other mix of the existing keywords; but if we wanted to allow the full combinations, we could insert them all here. The initial value is under debate in #2462 (and will likely be `space-first`).

**Interscript and Punctuation Space Insertion**

```
text-autospace:
    normal | auto | no-autospace |
    [ ideograph-alpha || ideograph-numeric || punctuation ]
    || [ insert | replace ]
```
The initial value would `normal` (currently defined as `ideograph-alpha ideograph-numeric`).

(`punctuation` is for languages like French, which want a narrow non-breaking space before ;:?! and an normal non-breaking space on the inside of « and ».)

To address one of @r12a’s requests in #7183 (split out as #8263), `insert` inserts spaces where there aren't any (as currently specced) while `replace` will do the same as insert, but also replace incorrect spaces (U+0020 and U+00A0) with correct spacing.

**Compression Control**
```
text-justify: <current-stuff> || no-compress
```

This moves `no-compress` into the `text-justify` property, which is the “how do I justify” control. It would not be reset by the `text-spacing` shorthand, which is probably better.

**Shorthand**
The shorthand for these would be:
```
text-spacing: normal | none | auto | <'text-autospace'> || <'text-spacing-trim'>
```
`normal` sets both to their initial values; `none` maps to `no-autospace space-all` (which is the “do nothing” value appropriate for e.g. monospace text, or to avoid compat issues with fiddly legacy content).

<hr>

**Excess Longhands**
It might be reasonable for the two functions of `text-autospace` to cascade independently, so it could have further longhands (names TBD):
* `text-autospace-style: normal | no-autospace | auto | [cjk-alpha || cjk-num || punctuation ]` with initial value `normal`
* `text-autospace-mode: insert | replace` with initial value `insert`

`text-spacing-trim` could also have further long-hands as described in https://github.com/w3c/csswg-drafts/issues/8288#issuecomment-1375213160, with a full explosion of possible combinations. However, these seem unnecessary (as most combinations aren't actually useful) and possibly a cascade footgun (if authors try and tweak something on top of an assumed base behavior using a longhand, without noticing that the other longhands have a cascaded behavior different from what they assumed would be there as the base behavior).

-- 
GitHub Notification of comment by fantasai
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/4246#issuecomment-1404738513 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Thursday, 26 January 2023 09:24:54 UTC