- From: David Choi via GitHub <sysbot+gh@w3.org>
- Date: Tue, 25 Jul 2023 02:00:54 +0000
- To: public-css-archive@w3.org
RWDavid has just created a new issue for https://github.com/w3c/csswg-drafts: == [css-text-4] Should `text-wrap: balance` apply separate logic before and after forced breaks? == Relevant spec: https://drafts.csswg.org/css-text-4/#valdef-text-wrap-balance Currently, `text-wrap: balance` applies to the line boxes of an inline formatting context. > Line boxes are balanced when the standard deviation from the average [inline-size](https://drafts.csswg.org/css-writing-modes-4/#inline-size) of the remaining space in each line box is reduced over the block (including lines that end in a forced break). However, it is unclear whether inline content broken apart by a `<br>` should cause `text-wrap: balance` to treat them as two separate 'units' to be balanced. For example, given the following code snippet: ``` <style> div { width: 20em; text-wrap: balance; } </style> <div> Paragraph A: Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. <br> Paragraph B: Feugiat in fermentum posuere urna nec tincidunt praesent. Porttitor lacus luctus accumsan tortor posuere ac ut. Aliquet porttitor lacus luctus accumsan tortor. Nibh sed pulvinar. </div> ``` Should the browser attempt to balance Paragraphs A and B individually (with the goal of reducing variance of line lengths within each paragraph) or together (with the goal of reducing overall line length variance)? I did some investigation into some text-balancing algorithms, and it's worth noting that some algorithms will produce virtually identical line-breaking decisions regardless of balancing them together or separately. For example, if you define a cost function to be $f(w) = (w - \overline{w})^2$, where $w$ is a candidate line width and $\overline{w}$ is the ideal/average line width, then minimizing this cost function across all lines will result in identical line-breaking decisions. This cost function also models variance pretty well. However, for other text-balancing algorithms, applying them on individual paragraphs delimited by forced breaks can result in different line breaking decisions, so I think it's worth trying to clarify this now. Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/9112 using your GitHub account -- Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config
Received on Tuesday, 25 July 2023 02:00:56 UTC