JDK-8119761 : [Text] Caret shape is in wrong location when at end of RTL text.
  • Type: Bug
  • Component: javafx
  • Sub-Component: graphics
  • Affected Version: 8
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • Submitted: 2012-11-27
  • Updated: 2015-06-17
  • Resolved: 2012-12-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.
JDK 8
8Fixed
Related Reports
Relates :  
Relates :  
Description
When moving the cursor over pure RTL text in TextField, the caret moves forwards (left-wards) until it hits the last position, i.e. the position after the last character, and then  it jumps to the far right again.

Here is a simple test case:

import javafx.application.*;
import javafx.scene.shape.*;
import javafx.scene.text.*;
import javafx.stage.*;

public class TextTest extends Application {

    public static void main(String[] args) { launch(args); }

    @Override public void start(Stage stage) {
        Text text = new Text("\u05E9\u05E0");

        for (int i = 0; i <= text.getText().length(); i++) {
            text.setImpl_caretPosition(i);
            System.err.println("caretPos=" + i + ", caretX=" + ((MoveTo)text.getImpl_caretShape()[0]).getX());
        }
        System.exit(0);
    }
}

Output:
caretPos=0, caretX=14.41552734375
caretPos=1, caretX=5.205078125
caretPos=2, caretX=14.41552734375


Comments
Verified on 8.0b105
04-09-2013

8.0b105: caretPos=0, caretX=14.595703125 caretPos=1, caretX=4.810546875 caretPos=2, caretX=0.0 Run=0 start=0 end=2 level=1
04-09-2013

http://jfxsrc.us.oracle.com/javafx/8.0/scrum/graphics/rt-closed/rev/8323a36cbdf1
26-12-2012

We've filed this as a bug in JDK7's bidi implementation: https://jbs.oracle.com/bugs/browse/JDK-8005277 As we were were mostly running FX on JDK 6 this could easily have been overlooked.
19-12-2012

Leif, Phil: is there any bidi algorithm expert that could verify my findings ? Note: I'm quite positive this is bug, in the place where I call getRunLevel() and it returns zero, if I use getLevelAt(bidi.getRunStart(i)) it returns 1.
18-12-2012

That seens like a bug in Bidi to me, see void printRuns(String string) { Bidi bidi = new Bidi(string, Bidi.DIRECTION_LEFT_TO_RIGHT); for (int i = 0, count = bidi.getRunCount(); i < count; i++) { System.out.println("Run=" + i + " start=" + bidi.getRunStart(i) + " end=" + bidi.getRunLimit(i) + " level=" + bidi.getRunLevel(i)); } } Calling with "\u05D0\u05D1\u05D2" I get Run=0 start=0 end=3 level=0 That should not be level 0!!! The right answer is level 1. Calling with "\u05D0\u05D1\u05D2felipe\u05D0\u05D1\u05D2" I looks good: Run=0 start=0 end=3 level=1 Run=1 start=3 end=9 level=0 Run=2 start=9 end=12 level=1 I noticed that the bug goes away if I replaced DIRECTION_LEFT_TO_RIGHT with DIRECTION_DEFAULT_LEFT_TO_RIGHT Leif, are you aware of bug in the Bidi implementation ?
18-12-2012