+ }
+
+ // Set the first paragraph's direction.
+ CharacterDirection paragraphDirection = ( NULL != layoutParameters.characterDirectionBuffer ) ? *layoutParameters.characterDirectionBuffer : !RTL;
+
+ // Whether the layout is being updated or set from scratch.
+ const bool updateCurrentBuffer = layoutParameters.numberOfGlyphs < layoutParameters.totalNumberOfGlyphs;
+
+ Vector2* glyphPositionsBuffer = NULL;
+ Vector<Vector2> newGlyphPositions;
+
+ LineRun* linesBuffer = NULL;
+ Vector<LineRun> newLines;
+
+ // Estimate the number of lines.
+ Length linesCapacity = std::max( 1u, layoutParameters.estimatedNumberOfLines );
+ Length numberOfLines = 0u;
+
+ if( updateCurrentBuffer )
+ {
+ newGlyphPositions.Resize( layoutParameters.numberOfGlyphs );
+ glyphPositionsBuffer = newGlyphPositions.Begin();
+
+ newLines.Resize( linesCapacity );
+ linesBuffer = newLines.Begin();
+ }
+ else
+ {
+ glyphPositionsBuffer = glyphPositions.Begin();
+
+ lines.Resize( linesCapacity );
+ linesBuffer = lines.Begin();
+ }
+
+ float penY = SetParagraphOffset( lines,
+ layoutParameters.startLineIndex );
+
+ for( GlyphIndex index = layoutParameters.startGlyphIndex; index < lastGlyphPlusOne; )
+ {
+ CharacterDirection currentParagraphDirection = paragraphDirection;
+
+ // Get the layout for the line.
+ LineLayout layout;
+ layout.glyphIndex = index;
+ GetLineLayoutForBox( layoutParameters,
+ layout,
+ paragraphDirection,
+ false );
+
+ DALI_LOG_INFO( gLogFilter, Debug::Verbose, " glyph index %d\n", layout.glyphIndex );
+ DALI_LOG_INFO( gLogFilter, Debug::Verbose, " character index %d\n", layout.characterIndex );
+ DALI_LOG_INFO( gLogFilter, Debug::Verbose, " number of glyphs %d\n", layout.numberOfGlyphs );
+ DALI_LOG_INFO( gLogFilter, Debug::Verbose, " number of characters %d\n", layout.numberOfCharacters );
+ DALI_LOG_INFO( gLogFilter, Debug::Verbose, " length %f\n", layout.length );
+
+ if( 0u == layout.numberOfGlyphs )
+ {
+ // The width is too small and no characters are laid-out.
+ DALI_LOG_INFO( gLogFilter, Debug::Verbose, "<--LayoutText width too small!\n\n" );
+
+ lines.Resize( numberOfLines );
+ return false;
+ }
+
+ // Set the line position. Discard if ellipsis is enabled and the position exceeds the boundaries
+ // of the box.
+ penY += layout.ascender;
+
+ DALI_LOG_INFO( gLogFilter, Debug::Verbose, " pen y %f\n", penY );
+
+ bool ellipsis = false;
+ if( mEllipsisEnabled )
+ {
+ // Does the ellipsis of the last line.
+ ellipsis = EllipsisLine( layoutParameters,
+ layout,
+ layoutSize,
+ linesBuffer,
+ glyphPositionsBuffer,
+ numberOfLines,
+ penY,
+ currentParagraphDirection );
+ }
+
+ if( ellipsis )
+ {
+ // No more lines to layout.