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

Michael Strauß mstrauss at openjdk.org
Mon Oct 30 19:11:42 UTC 2023


On Mon, 30 Oct 2023 08:52:27 GMT, John Hendrikx <jhendrikx at openjdk.org> wrote:

> > I've tested `AAA BBB CCC` in Chrome, and the text is rendered pretty much exactly as your "before" version:
> 
> For the current rendering that JavaFX does, there is no browser equivalent, although `pre-wrap` comes close, JavaFX will take the spaces into account when adding the ellipsis (in HTML can test with `overflow: hidden; text-overflow: ellipsis;`) and displays odd empty lines in between the cut-off lines (see the 2nd before picture). I suppose this could also be considered a separate bug.
> 
> For browsers, `pre-line` is the `normal` equivalent that preserves spaces; this probably should be the default setting for FX as spaces are considered significant in FX controls. This what this PR provides.
> 
> Although I definitely think the `pre-line` (or `normal` but preserving white space) rendering should have been standard from the beginning, this could be provided with a CSS style (but that will need a default as well, and the current one isn't ideal as default IMHO). I'm however not sure if that's really worth it as JavaFX labels and text fields are quite different from browser elements. I'm unaware of other UI toolkits offering such settings.

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.

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.

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

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


More information about the openjfx-dev mailing list