@@ -134,7 +134,7 @@ public class TextRenderer extends AbstractRenderer implements ILeafElementRender
134
134
135
135
private int specialScriptFirstNotFittingIndex = -1 ;
136
136
137
- private boolean layoutUntilTheLastPossibleBreak = false ;
137
+ private int firstIndexExceedingAvailableWidth = - 1 ;
138
138
139
139
/**
140
140
* Creates a TextRenderer from its corresponding layout object.
@@ -343,8 +343,10 @@ public LayoutResult layout(LayoutContext layoutContext) {
343
343
&& RenderingMode .HTML_MODE == mode ) {
344
344
containsPossibleBreak = true ;
345
345
}
346
- if (ind + 1 == text .end || nextGlyphIsSpaceOrWhiteSpace ) {
347
- if (ind + 1 == text .end && layoutUntilTheLastPossibleBreak ) {
346
+ if (ind + 1 == text .end || nextGlyphIsSpaceOrWhiteSpace
347
+ || (ind + 1 >= firstIndexExceedingAvailableWidth
348
+ && firstIndexExceedingAvailableWidth != -1 )) {
349
+ if (ind + 1 >= firstIndexExceedingAvailableWidth && firstIndexExceedingAvailableWidth != -1 ) {
348
350
firstCharacterWhichExceedsAllowedWidth = currentTextPos ;
349
351
break ;
350
352
} else {
@@ -434,8 +436,9 @@ && findPossibleBreaksSplitPosition(specialScriptsWordBreakPoints,
434
436
}
435
437
if (ind + 1 == text .end
436
438
|| endOfNonBreakablePartCausedBySplitCharacter
437
- || endOfWordBelongingToSpecialScripts ) {
438
- if (ind + 1 == text .end && layoutUntilTheLastPossibleBreak
439
+ || endOfWordBelongingToSpecialScripts
440
+ || (ind + 1 >= firstIndexExceedingAvailableWidth && firstIndexExceedingAvailableWidth != -1 )) {
441
+ if (ind + 1 >= firstIndexExceedingAvailableWidth && firstIndexExceedingAvailableWidth != -1
439
442
&& !endOfNonBreakablePartCausedBySplitCharacter ) {
440
443
firstCharacterWhichExceedsAllowedWidth = currentTextPos ;
441
444
}
@@ -493,7 +496,7 @@ && findPossibleBreaksSplitPosition(specialScriptsWordBreakPoints,
493
496
boolean wordSplit = false ;
494
497
boolean hyphenationApplied = false ;
495
498
496
- if (hyphenationConfig != null && ! layoutUntilTheLastPossibleBreak ) {
499
+ if (hyphenationConfig != null && firstIndexExceedingAvailableWidth == - 1 ) {
497
500
if (-1 == nonBreakingHyphenRelatedChunkStart ) {
498
501
int [] wordBounds = getWordBoundsForHyphenation (text , currentTextPos , text .end , Math .max (currentTextPos , firstCharacterWhichExceedsAllowedWidth - 1 ));
499
502
if (wordBounds != null ) {
@@ -1303,8 +1306,8 @@ int getSpecialScriptFirstNotFittingIndex() {
1303
1306
return specialScriptFirstNotFittingIndex ;
1304
1307
}
1305
1308
1306
- void setLayoutUntilTheLastPossibleBreak ( boolean layoutUntilTheLastPossibleBreak ) {
1307
- this .layoutUntilTheLastPossibleBreak = layoutUntilTheLastPossibleBreak ;
1309
+ void setFirstIndexExceedingAvailableWidth ( int firstIndexExceedingAvailableWidth ) {
1310
+ this .firstIndexExceedingAvailableWidth = firstIndexExceedingAvailableWidth ;
1308
1311
}
1309
1312
1310
1313
@ Override
0 commit comments