Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8145496

Incorrect TextLayout word wrap with right or center text alignment

XMLWordPrintable

    • x86_64
    • windows_7

      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.

            jhendrikx John Hendrikx
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: