+ // Do not layout more lines if ellipsis is enabled.
+
+ // The last line needs to be completely filled with characters.
+ // Part of a word may be used.
+
+ const Length numberOfLines = lines.Count();
+
+ LineRun lineRun;
+ LineLayout ellipsisLayout;
+ if( 0u != numberOfLines )
+ {
+ // Get the last line and layout it again with the 'completelyFill' flag to true.
+ lineRun = *( lines.Begin() + ( numberOfLines - 1u ) );
+
+ penY -= layout.ascender - lineRun.descender;
+
+ ellipsisLayout.glyphIndex = lineRun.glyphRun.glyphIndex;
+ }
+ else
+ {
+ lineRun.glyphRun.glyphIndex = 0u;
+ ellipsisLayout.glyphIndex = 0u;
+ }
+
+ GetLineLayoutForBox( layoutParameters,
+ ellipsisLayout,
+ currentParagraphDirection,
+ true );
+
+ lineRun.glyphRun.numberOfGlyphs = ellipsisLayout.numberOfGlyphs;
+ lineRun.characterRun.characterIndex = ellipsisLayout.characterIndex;
+ lineRun.characterRun.numberOfCharacters = ellipsisLayout.numberOfCharacters;
+ lineRun.width = ellipsisLayout.length;
+ lineRun.extraLength = ( ellipsisLayout.wsLengthEndOfLine > 0.f ) ? ellipsisLayout.wsLengthEndOfLine - ellipsisLayout.extraWidth : 0.f;
+ lineRun.ascender = ellipsisLayout.ascender;
+ lineRun.descender = ellipsisLayout.descender;
+ lineRun.direction = !RTL;
+ lineRun.ellipsis = true;
+
+ actualSize.width = layoutParameters.boundingBox.width;
+ actualSize.height += ( lineRun.ascender + -lineRun.descender );
+
+ SetGlyphPositions( layoutParameters.glyphsBuffer + lineRun.glyphRun.glyphIndex,
+ ellipsisLayout.numberOfGlyphs,
+ penY,
+ glyphPositions.Begin() + lineRun.glyphRun.glyphIndex );
+
+ if( 0u != numberOfLines )
+ {
+ // Set the last line with the ellipsis layout.
+ *( lines.Begin() + ( numberOfLines - 1u ) ) = lineRun;
+ }
+ else
+ {
+ // Push the line.
+ lines.PushBack( lineRun );
+ }
+