Skip to content

Commit

Permalink
Changed staggered text detection (#1074)
Browse files Browse the repository at this point in the history
Previous implementation wasn't DPI robust. See #1071 [comment](#1071 (comment))
  • Loading branch information
Jugen authored Jan 28, 2022
1 parent 3877909 commit eb19540
Showing 1 changed file with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ int getLineCount() {

lineCount = 0;
lineMetrics.clear();
double totLines = 0.0, prevMinY = 1.0, prevMaxY = -1.0;
double totLines = 0.0, prevMaxY = -1.0;
int totCharSoFar = 0;

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

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

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

Expand Down Expand Up @@ -120,8 +120,7 @@ int getLineCount() {
totCharSoFar += length;
}

prevMaxY = nodeBounds.getMaxY();
prevMinY = nodeMinY;
prevMaxY = Math.max( prevMaxY, nodeBounds.getMaxY() );
}

lineCount = (int) totLines;
Expand Down

0 comments on commit eb19540

Please sign in to comment.