JDK-8145496 : Incorrect TextLayout word wrap with right or center text alignment
  • Type: Bug
  • Component: javafx
  • Sub-Component: graphics
  • Affected Version: 8u60
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_7
  • CPU: x86_64
  • Submitted: 2015-12-10
  • Updated: 2024-06-03
  • Resolved: 2024-04-26
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
tbdResolved
Related Reports
Duplicate :  
Relates :  
Description
FULL PRODUCT VERSION :


A DESCRIPTION OF THE PROBLEM :
Word wrapped lines in text (e.g. Text node) with right alignment frequently have wrong offsets from the right edge. Further, it can have different offsets for different lines, as in the provided example. The same observed in centered text. 

The cause is that PrismTextLayout.layout() retains  spaces at soft break line boundaries when calculating text runs. 

Because  line end is aligned to right edge, some lines have space before text on the right and then such line is misaligned. In centered text, the line can be shifted right or left as well.

Skipping spaces that happen around soft break in PrismTextLayout.layout() fixes the issue. 

----
fedor.losev@gmail.com if more info is needed.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        Text text = new Text();
        text.setText("test1 test2 test3 asdasd asdas dasd asdas dasdas sfagadsdg asdfglskdjg sadfgsad fljkasdf asasd sadas");
        root.getChildren().add(text);
        text.setStyle("-fx-font-size:18;-fx-font-family: Arial;");
        text.setTextAlignment(TextAlignment.RIGHT);
        text.setWrappingWidth(70);

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
All wrapped lines have the same 0 offset from the right edge.
ACTUAL -
Lines have different offset from right. 

REPRODUCIBILITY :
This bug can be reproduced always.


Comments
This will be addressed with a fix for JDK-8314215
26-04-2024

Possible duplicate of JDK-8314215. [~jhendrikx] Can you verify that this is addressed by the fix for JDK-8314215? If so, please close it as a duplicate.
26-04-2024

The Rampdown phase start [1] milestone is approaching, it means we are not targeting "9" to fix P4s anymore, unless the fix is ready and not risky, safe enough not introduce P2-P3 regressions; if this is a case you can retarget back to "9" right before the push the reviewed code. [1] http://openjdk.java.net/projects/jdk8/milestones#Rampdown_start
29-08-2016