@@ -116,7 +116,7 @@ public class TextRenderer : AbstractRenderer, ILeafElementRenderer {
116
116
117
117
private int specialScriptFirstNotFittingIndex = - 1 ;
118
118
119
- private bool layoutUntilTheLastPossibleBreak = false ;
119
+ private int firstIndexExceedingAvailableWidth = - 1 ;
120
120
121
121
/// <summary>Creates a TextRenderer from its corresponding layout object.</summary>
122
122
/// <param name="textElement">
@@ -303,8 +303,9 @@ public override LayoutResult Layout(LayoutContext layoutContext) {
303
303
== mode ) {
304
304
containsPossibleBreak = true ;
305
305
}
306
- if ( ind + 1 == text . end || nextGlyphIsSpaceOrWhiteSpace ) {
307
- if ( ind + 1 == text . end && layoutUntilTheLastPossibleBreak ) {
306
+ if ( ind + 1 == text . end || nextGlyphIsSpaceOrWhiteSpace || ( ind + 1 >= firstIndexExceedingAvailableWidth &&
307
+ firstIndexExceedingAvailableWidth != - 1 ) ) {
308
+ if ( ind + 1 >= firstIndexExceedingAvailableWidth && firstIndexExceedingAvailableWidth != - 1 ) {
308
309
firstCharacterWhichExceedsAllowedWidth = currentTextPos ;
309
310
break ;
310
311
}
@@ -386,8 +387,8 @@ public override LayoutResult Layout(LayoutContext layoutContext) {
386
387
containsPossibleBreak = true ;
387
388
}
388
389
if ( ind + 1 == text . end || endOfNonBreakablePartCausedBySplitCharacter || endOfWordBelongingToSpecialScripts
389
- ) {
390
- if ( ind + 1 == text . end && layoutUntilTheLastPossibleBreak && ! endOfNonBreakablePartCausedBySplitCharacter
390
+ || ( ind + 1 >= firstIndexExceedingAvailableWidth && firstIndexExceedingAvailableWidth != - 1 ) ) {
391
+ if ( ind + 1 >= firstIndexExceedingAvailableWidth && firstIndexExceedingAvailableWidth != - 1 && ! endOfNonBreakablePartCausedBySplitCharacter
391
392
) {
392
393
firstCharacterWhichExceedsAllowedWidth = currentTextPos ;
393
394
}
@@ -440,7 +441,7 @@ public override LayoutResult Layout(LayoutContext layoutContext) {
440
441
// cannot fit a word as a whole
441
442
bool wordSplit = false ;
442
443
bool hyphenationApplied = false ;
443
- if ( hyphenationConfig != null && ! layoutUntilTheLastPossibleBreak ) {
444
+ if ( hyphenationConfig != null && firstIndexExceedingAvailableWidth == - 1 ) {
444
445
if ( - 1 == nonBreakingHyphenRelatedChunkStart ) {
445
446
int [ ] wordBounds = GetWordBoundsForHyphenation ( text , currentTextPos , text . end , Math . Max ( currentTextPos , firstCharacterWhichExceedsAllowedWidth
446
447
- 1 ) ) ;
@@ -841,7 +842,7 @@ public override void Draw(DrawContext drawContext) {
841
842
if ( horizontalScaling != null && horizontalScaling != 1 ) {
842
843
canvas . SetHorizontalScaling ( ( float ) horizontalScaling * 100 ) ;
843
844
}
844
- GlyphLine . IGlyphLineFilter filter = new _IGlyphLineFilter_909 ( ) ;
845
+ GlyphLine . IGlyphLineFilter filter = new _IGlyphLineFilter_912 ( ) ;
845
846
bool appearanceStreamLayout = true . Equals ( GetPropertyAsBoolean ( Property . APPEARANCE_STREAM_LAYOUT ) ) ;
846
847
if ( GetReversedRanges ( ) != null ) {
847
848
bool writeReversedChars = ! appearanceStreamLayout ;
@@ -903,8 +904,8 @@ public override void Draw(DrawContext drawContext) {
903
904
}
904
905
}
905
906
906
- private sealed class _IGlyphLineFilter_909 : GlyphLine . IGlyphLineFilter {
907
- public _IGlyphLineFilter_909 ( ) {
907
+ private sealed class _IGlyphLineFilter_912 : GlyphLine . IGlyphLineFilter {
908
+ public _IGlyphLineFilter_912 ( ) {
908
909
}
909
910
910
911
public bool Accept ( Glyph glyph ) {
@@ -1250,8 +1251,8 @@ internal virtual int GetSpecialScriptFirstNotFittingIndex() {
1250
1251
return specialScriptFirstNotFittingIndex ;
1251
1252
}
1252
1253
1253
- internal virtual void SetLayoutUntilTheLastPossibleBreak ( bool layoutUntilTheLastPossibleBreak ) {
1254
- this . layoutUntilTheLastPossibleBreak = layoutUntilTheLastPossibleBreak ;
1254
+ internal virtual void SetFirstIndexExceedingAvailableWidth ( int firstIndexExceedingAvailableWidth ) {
1255
+ this . firstIndexExceedingAvailableWidth = firstIndexExceedingAvailableWidth ;
1255
1256
}
1256
1257
1257
1258
protected internal override Rectangle GetBackgroundArea ( Rectangle occupiedAreaWithMargins ) {
0 commit comments