Re: [csswg-drafts] [css-text] Preventing too-short final lines of blocks (Last Line Minimum Length) (#3473)

The CSS Working Group just discussed `[css-text] Preventing too-short final lines of blocks (Last Line Minimum Length)`, and agreed to the following:

* `RESOLVED: Add a control that is either a property or a value that causes UAs to make the last line longer than it would've originally done unless that was a bad idea`

<details><summary>The full IRC log of that discussion</summary>
&lt;fantasai> myles: this is a small issue ....<br>
&lt;fantasai> myles: We have had many requests throughout the years where typographers and designers have come to us and show us a paragraph on the web page<br>
&lt;fantasai> myles: they'll point to last line and say, 'this last line is tooooo narrow"<br>
&lt;fantasai> myles: this has a name, it's called orphans and widows<br>
&lt;fantasai> myles: also term has two meanings<br>
&lt;fantasai> myles: CSS has support for the other meaning (pagination)<br>
&lt;fantasai> myles: but for this one, doesn't<br>
&lt;fantasai> myles: this is one of our highest requested text-related features<br>
&lt;fantasai> myles: so it would be cool if CSS could solve<br>
&lt;fantasai> myles: problem here is that last line is too narrow, so get wide paragraph and maybe one word on last line. Looks bad<br>
&lt;fantasai> myles: more nuance, but what I will say is, I think there's two potential solutions<br>
&lt;fantasai> myles: one is a new property, and one is a change to value space of `text-wrap: pretty`<br>
&lt;Rossen_> q?<br>
&lt;fantasai> myles: so could invent a new property or add a thing that when you do pretty, try to focus on the last line<br>
&lt;Rossen_> ack emilio<br>
&lt;fremy> lol<br>
&lt;florian> q+<br>
&lt;iank_> q+<br>
&lt;fantasai> florian: text-wrap: pretty solves this and more, and is expensive<br>
&lt;fantasai> florian: and that's important<br>
&lt;fantasai> florian: if it wasn't expensive, just using pretty would be fine<br>
&lt;fantasai> florian: there are terrible solutions to this problem<br>
&lt;fantasai> florian: if you implement one that is "good enough"<br>
&lt;Rossen_> ack florian<br>
&lt;fantasai> florian: is there enough perf difference with pretty that it's worth a separate control<br>
&lt;fantasai> hober: very significant perf difference<br>
&lt;fantasai> myles: naive implementation of pretty is exponentially bad perf<br>
&lt;fantasai> myles: whereas an algorithm that just focuses on this problem would be at worst linear, but almost constant time<br>
&lt;nicole> q+<br>
&lt;Rossen_> ack iank_<br>
&lt;fantasai> iank_: yes, expensive, but we might have different perspectives on how expensive we're willing to tolerate for pretty<br>
&lt;fantasai> iank_: lot of nuance there, let's not get into it now<br>
&lt;fantasai> iank_: from our perspective, if there is a control, it would be nice if it could also control pretty<br>
&lt;fantasai> iank_: fundamentally, pretty does have a lot of knobs like "how much to bias for x consideration"<br>
&lt;fantasai> myles: if independent control for last line and pretty, browser could see and modify pretty to focus on last line<br>
&lt;fantasai> iank_: potentially<br>
&lt;fantasai> myles: that sounds great<br>
&lt;Rossen_> ack nicole<br>
&lt;fantasai> nicole: I wanted to ask, how many lines would be impacted by that<br>
&lt;fantasai> myles: I think we're flexible here, not super clear what the spec should say<br>
&lt;astearns> -1 to only stealing words from one line<br>
&lt;fantasai> myles: if we were to implement this, first version would start at 1 line and then iterate from there and see if need to increase<br>
&lt;fantasai> nicole: similar to headline balancing?<br>
&lt;fantasai> iank_: not really<br>
&lt;florian> q+<br>
&lt;fantasai> hober: taking a first pass would only use one line, but I can imagine empiricially discovering that we can tolerate 3-4  and might have a spec, but let's not prematurely decide<br>
&lt;Rossen_> ack florian<br>
&lt;fantasai> florian: are you aiming for a yes/no property or are you thinking of giving author control like at least 3em or at least 30%<br>
&lt;fantasai> myles: flexible<br>
&lt;fantasai> myles: Firstly, we now using words is long<br>
&lt;fantasai> myles: not clear, in i18n context, what exactly a word is<br>
&lt;astearns> s/long/wrong/<br>
&lt;fantasai> myles: from implementation perspective, can make a boolean<br>
&lt;fantasai> myles: if authors need more control, can add<br>
&lt;fantasai> myles: when authors request this, they usually request a percentage<br>
&lt;fantasai> myles: e.g. at least 15%<br>
&lt;florian> q?<br>
&lt;Rossen_> s/15%/50%/<br>
&lt;fantasai> iank_: is that what they actually want, or think that's the tool that indesign provides...<br>
&lt;fantasai> myles: I don't know, but my proposal is a boolean switch<br>
&lt;florian> q+<br>
&lt;astearns> q+<br>
&lt;fantasai> myles: and as implementations progress, we can see if that makes sense or not<br>
&lt;florian> q- later<br>
&lt;fantasai> smfr: should we just resolve on adding a property without specifying if boolean or not?<br>
&lt;Rossen_>  ack astearns<br>
&lt;fantasai> astearns: for a prperty that does only this one thing<br>
&lt;fantasai> astearns: I would advocate strongly for just a boolean switch<br>
&lt;fantasai> astearns: anything more finely grained is really going to have to be weighed against other line-breaking considerations<br>
&lt;fantasai> astearns: and needs to modify results of pretty<br>
&lt;fantasai> astearns: if we're separating the two, then the simple thing, should just be a boolean<br>
&lt;fremy> q+<br>
&lt;Rossen_> ack florian<br>
&lt;fantasai> florian: I think I support this because of the perf difference<br>
&lt;fantasai> florian: but even then it does feel like it's a variant of pretty, you've decided what you care about<br>
&lt;fantasai> florian: so is it really separate from pretty?<br>
&lt;fremy> wanted to say the same thing<br>
&lt;fremy> q-<br>
&lt;emilio> fantasai: There are a lot of knobs that factor into pretty and a lot of them are already separate knobs<br>
&lt;fremy> q+<br>
&lt;emilio> ... In level 4 or some other we had word-spacing and letter-spacing give you the optimal value but we also give you a range for the line-breaker to play with<br>
&lt;iank_> q+<br>
&lt;emilio> ... that's a factor into the line breaker<br>
&lt;emilio> ... same for hyphenation controls<br>
&lt;emilio> ... these are already split out into multiple controls<br>
&lt;emilio> ... turning on pretty shouldn't need to redeclare your controls<br>
&lt;emilio> ... so should cascade separately<br>
&lt;emilio> ... I agree with myles, we should have this tweak<br>
&lt;florian> [Florian is convinced]<br>
&lt;emilio> ... I'd like something that can be applied to the html spec and not spin for 10 minutes<br>
&lt;emilio> ... I also agree with astearns that you have to look a more than one line<br>
&lt;nicole> q+<br>
&lt;emilio> ... A boolean switch is fine but we should define this thinking of extending it to percentages too<br>
&lt;myles> sooooo `minimum-last-line-length: normal | auto [maybe more in the future]`<br>
&lt;emilio> fantasai: If we spec it out we need to pick a name that's gonna work for both<br>
&lt;emilio> ack fantasai<br>
&lt;florian> q+<br>
&lt;fantasai> fremy: I have a similar thought, that just looking at one line doesn't cut it<br>
&lt;Rossen_> ack fremy<br>
&lt;fantasai> fremy: you will end up with a triangle. If you have only two lines it's fine, if you have three, you'll have a long first line, then a smaller second line, and even smaller third line. Very strange<br>
&lt;fantasai> fremy: so in a way I'm struggling, if you have elements with more than two line, oh an implementation can produce good results without balancing lines from where it's stealing the words<br>
&lt;fantasai> fremy: I don't think I can see how to make it different from pretty<br>
&lt;fantasai> fremy: if you're doing that you're back with pretty<br>
&lt;fantasai> astearns: I am convinced that there is a faster linebreaking algorithm that would only do this and not look at the full "pretty" penalty values<br>
&lt;fantasai> astearns: it doesn't have to be as expensive as the full pretty implementation to do just this one thing<br>
&lt;fantasai> iank_: but you can bias the pretty implementation<br>
&lt;emilio> `text-balance: pretty-fast` :-)<br>
&lt;Rossen_> ack iank_<br>
&lt;fantasai> iank_: One thing on controls, it's not clear how this control would apply to `text-wrap: balance`<br>
&lt;fantasai> fantasai: it wouldn't<br>
&lt;astearns> but I absolutely agree that we should avoid introducing the line wrap triangle shapes that fremy described<br>
&lt;fantasai> myles: `balance` will win. it handles last line by itself<br>
&lt;fantasai> iank_: it feels to me that we have at least 3 line-wrapping algorithms, might have others in the future<br>
&lt;fantasai> iank_: this control wouldn't affect balance<br>
&lt;fantasai> fantasai: it also doesn't affect nowrap<br>
&lt;fantasai> iank_: sure<br>
&lt;hober> qq+<br>
&lt;fantasai> iank_: I somewhat agree with fremy that you might be getting into pretty territory<br>
&lt;ntim> q+<br>
&lt;fantasai> iank_: I'm not convinced by the global control argument<br>
&lt;fantasai> hober: if setting balance means it doesn't apply, then you aren't setitng whatever this is<br>
&lt;ntim> +1 to what hober said<br>
&lt;fantasai> hober: you're not setting it if you're not setting `text-wrap: balance`<br>
&lt;Rossen_> ack hober<br>
&lt;Zakim> hober, you wanted to react to iank_<br>
&lt;Rossen_> ack nicole<br>
&lt;fantasai> nicole: does anyone want orphans? is anyone like "I want to turn off nice ending to my text"<br>
&lt;fantasai> astearns: yes, because you will get faster text composition<br>
&lt;Rossen_> ack florian<br>
&lt;fantasai> florian: I suspect we all agree, but will say explicitly, when that is turned on it is a request for the browser to *attempt* to make the last line not terrible<br>
&lt;fantasai> florian: but if can only do this by making some other line terrible, shouldn't do it<br>
&lt;fantasai> [agreed]<br>
&lt;fantasai> florian: also agreeing with Tess that it's also a text wrap value<br>
&lt;fantasai> florian: and can have it as an additional keyword<br>
&lt;fantasai> myles: requested resolution isn't any particular grammar<br>
&lt;fantasai> ntim: I want to echo what tess said, it feels like text-wrap extension<br>
&lt;SebastianZ> q+<br>
&lt;Rossen_> ack ntim<br>
&lt;Rossen_> ack fantasai<br>
&lt;astearns> fantasai: so all of this is why I did not want this in text-wrap<br>
&lt;ntim> q+<br>
&lt;astearns> fantasai: whether and how you are wrapping should be separate<br>
&lt;emilio> fantasai: because it needs to cascade separately<br>
&lt;florian> +1<br>
&lt;emilio> ... you want to set the controls in a single place in your stylesheet<br>
&lt;myles> q+<br>
&lt;astearns> and if we want this to be extensible as a text-wrap: pretty control it needs to be separate<br>
&lt;emilio> ... this needs to be a separate thing and honestly I think `pretty` should have as well<br>
&lt;emilio> ... I think this gets into how we're wrapping and that should only set once<br>
&lt;florian> q?<br>
&lt;ntim> q-<br>
&lt;fantasai> This is why I was against "text-wrap: pretty" as a syntax in the first place<br>
&lt;emilio> Rossen_: let's pause for a second. There's a clear proposal for a clear problem<br>
&lt;emilio> ... There are also ideas about how to do it performantly...<br>
&lt;emilio> ... we have plenty of engineers on the room, and we're getting into how to solve the issue, let's not do that<br>
&lt;emilio> ... let's go through the queue if you want to discuss syntax or how to solve it<br>
&lt;emilio> fantasai: what's the proposed solution?<br>
&lt;emilio> Rossen_: to have a property or a value that solves this problem in a more performant way to pretty<br>
&lt;Rossen_> ack SebastianZ<br>
&lt;emilio> SebastianZ: iterating on nicole's question<br>
&lt;emilio> ... if the algo can be made pretty fast, why can't it be the default?<br>
&lt;emilio> ... we also have text-decoration skip-ink<br>
&lt;emilio> ... but it was worthwhile having as a standard<br>
&lt;florian> [I think think we should open a separate issue to move "balance | stable | pretty" out of text-wrap, and probably add "avoid-orphans" there]<br>
&lt;emilio> Rossen_: let's close that bridge when we get to it<br>
&lt;Rossen_> ack myles<br>
&lt;emilio> PROPOSED: Add a control that is either a property or a value that causes UAs to make the last line longer than it would've originally done unless that was a bad idea<br>
&lt;emilio> RESOLVED: Add a control that is either a property or a value that causes UAs to make the last line longer than it would've originally done unless that was a bad idea<br>
</details>


-- 
GitHub Notification of comment by css-meeting-bot
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/3473#issuecomment-1646267487 using your GitHub account


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

Received on Friday, 21 July 2023 21:44:30 UTC