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.
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.
- duplicates
-
JDK-8314215 Trailing Spaces before Line Breaks Affect the Center Alignment of Text
- Resolved
- relates to
-
JDK-8146182 Text alignment in Text node appears to be broken
- Closed