JDK-8318095 : TextArea/TextFlow: wrong layout in RTL mode
  • Type: Bug
  • Component: javafx
  • Sub-Component: controls
  • Affected Version: jfx21
  • Priority: P3
  • Status: Open
  • Resolution: Unresolved
  • Submitted: 2023-10-13
  • Updated: 2024-11-04
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
tbdUnresolved
Related Reports
Blocks :  
Relates :  
Relates :  
Relates :  
Relates :  
Description
The TextArea text layout gets messed up when the control is in RTL mode.

To reproduce, run the attached code and resize the window.  It is expected that the text is always visible and aligned right, but it's either goes out of the view or remains in its original position.

Editing seems to force the layout.

The issue can be seen with wrapText property on or off.

```
public class TextArea_RTL extends Application {

    @Override
    public void start(Stage stage) throws Exception {
        TextArea textArea = new TextArea();
        // also fails when wrap text is off
        textArea.setWrapText(true);
        textArea.setFont(Font.getDefault().font(24.0));
        textArea.setText("Arabic: العربية\nHebrew: עברית");

        Scene scene = new Scene(textArea);
        scene.setNodeOrientation(NodeOrientation.RIGHT_TO_LEFT);

        stage.setScene(scene);
        stage.setTitle("TextArea in RTL Mode");
        stage.show();
    }
}
```


(TextField behaves correctly)

edit 2023/10/26: same issue occurs in TextFlow
edit 2023/10/27: it looks like it also impacts caretShape() and rangeShape() computation