Skip to content

Commit

Permalink
danfickle#482: Added Workaround for lines only consisting of soft-hypen.
Browse files Browse the repository at this point in the history
This is a special case only for this single case: Line-Width is 0 and the
line only contains of a soft-hypen.  In this case we don't need to try to
break on the character level, as this will not work, but will lead to a
endless loop. So we pretend we already did try to break on the character
level. This ends the loop for this line.
  • Loading branch information
rototor committed May 18, 2020
1 parent 15870c3 commit 0b25c48
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,14 @@ public static LineBreakResult breakText(LayoutContext c,
context.setEnd(savedEnd);
continue LOOP;
} else {
if (context.getWidth() == 0) {
String calculatedSubstring = context.getCalculatedSubstring();
if (calculatedSubstring.length() == 1 && calculatedSubstring.charAt(0) == SOFT_HYPHEN) {
// Consists only of soft hypen, we have to break here and skip all togheter. We do not
// need to try breaking on the charater level, this will not work.
tryToBreakAnywhere = true;
}
}
// Else, retry it on a new line.
context.setEnd(savedEnd);
break LOOP;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,7 @@ private static void startNewInlineLine(LayoutContext c, BlockBox box, int breakA
* layout box.
* Otherwise, if there are floats and the current line is otherwise empty, moves below float and trys again.
* Otherwise, trys again on a new line.
* @return true if the line is finished, false if we must continue
*/
private static boolean startInlineText(
LayoutContext c, LineBreakContext lbContext, InlineBox inlineBox,
Expand Down

0 comments on commit 0b25c48

Please sign in to comment.