+ // 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 );
+ }
+
+ break;
+ }
+ else
+ {
+ const bool isLastLine = index + layout.numberOfGlyphs == layoutParameters.totalNumberOfGlyphs;
+
+ LineRun lineRun;
+ lineRun.glyphRun.glyphIndex = index;
+ lineRun.glyphRun.numberOfGlyphs = layout.numberOfGlyphs;
+ lineRun.characterRun.characterIndex = layout.characterIndex;
+ lineRun.characterRun.numberOfCharacters = layout.numberOfCharacters;
+ if( isLastLine && !layoutParameters.isLastNewParagraph )
+ {
+ const float width = layout.extraBearing + layout.length + layout.extraWidth + layout.wsLengthEndOfLine;
+ if( MULTI_LINE_BOX == mLayout )
+ {
+ lineRun.width = ( width > layoutParameters.boundingBox.width ) ? layoutParameters.boundingBox.width : width;
+ }
+ else
+ {
+ lineRun.width = width;
+ }
+
+ lineRun.extraLength = 0.f;
+ }
+ else
+ {
+ lineRun.width = layout.extraBearing + layout.length + layout.extraWidth;
+ lineRun.extraLength = ( layout.wsLengthEndOfLine > 0.f ) ? layout.wsLengthEndOfLine - layout.extraWidth : 0.f;
+ }
+ lineRun.ascender = layout.ascender;
+ lineRun.descender = layout.descender;
+ lineRun.direction = !RTL;
+ lineRun.ellipsis = false;
+
+ lines.PushBack( lineRun );
+
+ // Update the actual size.
+ if( lineRun.width > actualSize.width )
+ {
+ actualSize.width = lineRun.width;
+ }
+
+ actualSize.height += ( lineRun.ascender + -lineRun.descender );
+
+ SetGlyphPositions( layoutParameters.glyphsBuffer + index,
+ layout.numberOfGlyphs,
+ penY,
+ glyphPositions.Begin() + index );
+
+ penY += -layout.descender;
+
+ // Increase the glyph index.
+ index += layout.numberOfGlyphs;
+
+ if( isLastLine &&
+ layoutParameters.isLastNewParagraph &&
+ ( mLayout == MULTI_LINE_BOX ) )
+ {
+ // Need to add a new line with no characters but with height to increase the actualSize.height
+ const GlyphInfo& glyphInfo = *( layoutParameters.glyphsBuffer + layoutParameters.totalNumberOfGlyphs - 1u );
+
+ Text::FontMetrics fontMetrics;
+ mFontClient.GetFontMetrics( glyphInfo.fontId, fontMetrics );
+
+ LineRun lineRun;
+ lineRun.glyphRun.glyphIndex = 0u;
+ lineRun.glyphRun.numberOfGlyphs = 0u;
+ lineRun.characterRun.characterIndex = 0u;
+ lineRun.characterRun.numberOfCharacters = 0u;
+ lineRun.width = 0.f;
+ lineRun.ascender = fontMetrics.ascender;
+ lineRun.descender = fontMetrics.descender;
+ lineRun.extraLength = 0.f;
+ lineRun.alignmentOffset = 0.f;
+ lineRun.direction = !RTL;
+ lineRun.ellipsis = false;
+
+ actualSize.height += ( lineRun.ascender + -lineRun.descender );
+
+ lines.PushBack( lineRun );
+ }