[csswg-drafts] [css-inline-3] Add new value "auto" for initial-letter-align (#5398)

faceless2 has just created a new issue for https://github.com/w3c/csswg-drafts:

== [css-inline-3] Add new value "auto" for initial-letter-align ==
This was a bit of an aside in a comment at the bottom of https://github.com/w3c/csswg-drafts/issues/5244, but on reflection it warrants its own issue.

The `initial-letter-align` property sets the top/bottom alignment points to use from the paragraph - these are matched to the top/bottom of alignment points in the initial-letter itself. The default value is "alphabetic" with the option of setting "ideographic" or "hanging" - but the user-agent stylesheet chooses a default based on the language tag of the paragraph.

This issue is to suggest the addition of an "auto" value, which would be the default.

This would effectively resolve as one of the existing values based on the script property of the first characters of the paragraph following the initial-letter itself. Characters with "Common" or "Unknown" scripts are skipped over until we find a character with a "strong" script - then,
* if the script is Han, Hangul, Kana, or Yi, treat as `initial-letter-align: ideographic`
* if the script is Devanagari, Gurmukhi or Bengali, treat as `initial-letter-align: hanging`
* otherwise treat as `initial-letter-align: alphabetic`

(I'm presuming that "hebrew" will go away shortly as agreed)

So for example:

```css
p::first-letter {
    initial-letter: 2;
    initial-letter-align: auto
}
```
```html
<p>Bananas</p> 
<p>A "Big" Apple</p>
<p>2月14日</p>
<p>हिन्दी</p>
<p>2345</p>
<p>2<span style="float: right">float</span> more text</p>
```
Would result in:
* Initial letter is "B", followed by a "a"; "a" is Latin script, so "alphabetic" alignment is used
* Initial letter is "A", followed by a space and a quote, both of which are skipped as the script is common. The next letter is "B"; again "alphabetic" alignment is used
* Initial letter is 2, followed by a 月 so "ideographic" alignment is used
* Inital letter is the grapheme हि, followed by न्दी which is Devanagari script - "hanging" alignment is used
* Initial letter is 2, followed by "345" which are all common script. In the absence of any better information, the current default of "alphabetic" is used.
* Initial letter is 2, followed by a float. The two options here would be to skip the float entirely and find the first in-flow text following it ("more text"), or just collapse to alphabetic. We could also give user agents the choice, much like we do with the `::first-letter` pseudo-element when determining whether to group text following an initial punctuation character as part of the first-letter or not.

This has quite a few advantages.

1. It's future proof
2. It doesn't depend on correct language tagging
3. It doesn't need special handling in the user-agent stylesheet (a list of rules that must inevitably grow)
4. The same approach of "sniffing" the script from the glyph is already used for the initial-letter itself.

Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/5398 using your GitHub account


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

Received on Wednesday, 5 August 2020 13:52:08 UTC