RFR: JDK-8314215 Trailing Spaces before Line Breaks Affect the Center Alignment of Text

John Hendrikx jhendrikx at openjdk.org
Mon Oct 30 19:56:44 UTC 2023


On Mon, 30 Oct 2023 19:09:17 GMT, Michael Strauß <mstrauss at openjdk.org> wrote:

> It seems there's no browser equivalent to your proposed behavior, either. pre-line does not preserve spaces, but your proposal does; it merely doesn't preserve end-of-line spaces.

Yeah, I missed that somehow.  `pre-line` looks close but collapsed inter word spaces; `pre-wrap` doesn't, but its wrapping behavior is different.  I get the impression that `pre-wrap` is the one you want, but perhaps not correctly working Chrome?  Looks like browsers are disagreeing; Firefox is doing it differently (with `pre-wrap`):

![image](https://github.com/openjdk/jfx/assets/995917/7201ba07-a039-465b-b57a-7ea47b2bc2fd)

> While that might be a sensible default behavior, I'm not sure about the "invisible input" behavior that you'd get if you entered spaces at the end of a line.

That's done almost everywhere, just try it in the comment box here on Github for example.  Type sufficient text to reach the edge of the box, then type a lot of spaces.  They seem to "disappear", and they don't appear when the text reflows.  If you then cursor back, the cursor won't appear until you passed all the spaces you typed; or if you break the line in some other place, all those spaces are still there. It feels odd, but I think it is not a bad way to handle this kind of thing.

The example of MS Word that Nir showed also shows that the extra spaces just go past the margin.  Photoshop does the same (it's in one the tickets).

-------------

PR Comment: https://git.openjdk.org/jfx/pull/1236#issuecomment-1785936189


More information about the openjfx-dev mailing list