Skip to content

Commit eb19540

Browse files
authored
Changed staggered text detection (#1074)
Previous implementation wasn't DPI robust. See #1071 [comment](#1071 (comment))
1 parent 3877909 commit eb19540

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

richtextfx/src/main/java9/org/fxmisc/richtext/TextFlowLayout.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ int getLineCount() {
7272

7373
lineCount = 0;
7474
lineMetrics.clear();
75-
double totLines = 0.0, prevMinY = 1.0, prevMaxY = -1.0;
75+
double totLines = 0.0, prevMaxY = -1.0;
7676
int totCharSoFar = 0;
7777

7878
for ( Node n : flow.getChildren() ) if ( n.isManaged() ) {
@@ -83,8 +83,8 @@ int getLineCount() {
8383
double lines = Math.max( 1.0, Math.floor( shape.length / 5 ) );
8484
double nodeMinY = Math.max( 0.0, nodeBounds.getMinY() );
8585

86-
if ( nodeMinY >= prevMinY && lines > 1 ) totLines += lines - 1; // Multiline Text node
87-
else if ( nodeMinY >= prevMaxY ) totLines += lines;
86+
if ( nodeMinY >= prevMaxY ) totLines += lines;
87+
else if ( lines > 1 ) totLines += lines - 1; // Staggered multiline text node
8888

8989
if ( lineMetrics.size() < totLines ) { // Add additional lines
9090

@@ -120,8 +120,7 @@ int getLineCount() {
120120
totCharSoFar += length;
121121
}
122122

123-
prevMaxY = nodeBounds.getMaxY();
124-
prevMinY = nodeMinY;
123+
prevMaxY = Math.max( prevMaxY, nodeBounds.getMaxY() );
125124
}
126125

127126
lineCount = (int) totLines;

0 commit comments

Comments
 (0)