@@ -1093,11 +1093,14 @@ VerticalOrientationType.Rotate or
10931093 // Mandatory wrap at index.
10941094 if ( currentLineBreak . PositionWrap == codePointIndex && currentLineBreak . Required )
10951095 {
1096- textLines . Add ( textLine . Finalize ( ) ) ;
1097- glyphCount += textLine . Count ;
1098- textLine = new ( ) ;
1099- lineAdvance = 0 ;
1100- requiredBreak = true ;
1096+ if ( textLine . Count > 0 )
1097+ {
1098+ textLines . Add ( textLine . Finalize ( ) ) ;
1099+ glyphCount += textLine . Count ;
1100+ textLine = new ( ) ;
1101+ lineAdvance = 0 ;
1102+ requiredBreak = true ;
1103+ }
11011104 }
11021105 else if ( shouldWrap && lineAdvance + glyphAdvance >= wrappingLength )
11031106 {
@@ -1178,6 +1181,7 @@ VerticalOrientationType.Rotate or
11781181 }
11791182
11801183 // Find the next line break.
1184+ bool lastMandatory = lastLineBreak . Required ;
11811185 if ( currentLineBreak . PositionWrap == codePointIndex )
11821186 {
11831187 lastLineBreak = currentLineBreak ;
@@ -1199,9 +1203,22 @@ VerticalOrientationType.Rotate or
11991203 continue ;
12001204 }
12011205
1206+ // The previous line ended with a non-mandatory break at the wrapping length but the new line starts
1207+ // with a mandatory line break. We should not add a new line in this case as the line break has
1208+ // already been synthesized.
1209+ if ( textLine . Count == 0
1210+ && textLines . Count > 0
1211+ && ! lastMandatory
1212+ && CodePoint . IsNewLine ( codePoint ) )
1213+ {
1214+ codePointIndex ++ ;
1215+ graphemeCodePointIndex ++ ;
1216+ continue ;
1217+ }
1218+
1219+ // Do not add new lines unless at position zero.
12021220 if ( textLine . Count > 0 && CodePoint . IsNewLine ( codePoint ) )
12031221 {
1204- // Do not add new lines unless at position zero.
12051222 codePointIndex ++ ;
12061223 graphemeCodePointIndex ++ ;
12071224 continue ;
0 commit comments