+ // 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.
+ break;
+ }
+ else
+ {
+ // Whether the last line has been laid-out.
+ const bool isLastLine = index + layout.numberOfGlyphs == layoutParameters.totalNumberOfGlyphs;
+
+ if( numberOfLines == linesCapacity )
+ {
+ // Reserve more space for the next lines.
+ linesBuffer = ResizeLinesBuffer( lines,
+ newLines,
+ linesCapacity,
+ updateCurrentBuffer );
+ }
+
+ // Updates the current text's layout with the line's layout.
+ UpdateTextLayout( layoutParameters,
+ layout,
+ layoutSize,
+ linesBuffer,
+ index,
+ numberOfLines,
+ isLastLine );
+
+ const GlyphIndex nextIndex = index + layout.numberOfGlyphs;
+
+ if( ( nextIndex == layoutParameters.totalNumberOfGlyphs ) &&
+ layoutParameters.isLastNewParagraph &&
+ ( mLayout == MULTI_LINE_BOX ) )
+ {
+ // The last character of the text is a new paragraph character.
+ // An extra line with no characters is added to increase the text's height
+ // in order to place the cursor.
+
+ if( numberOfLines == linesCapacity )
+ {
+ // Reserve more space for the next lines.
+ linesBuffer = ResizeLinesBuffer( lines,
+ newLines,
+ linesCapacity,
+ updateCurrentBuffer );
+ }
+
+ UpdateTextLayout( layoutParameters,
+ layout.characterIndex + layout.numberOfCharacters,
+ index + layout.numberOfGlyphs,
+ layoutSize,
+ linesBuffer,
+ numberOfLines );
+ } // whether to add a last line.
+
+ // Sets the positions of the glyphs.
+ SetGlyphPositions( layoutParameters.glyphsBuffer + index,
+ layout.numberOfGlyphs,
+ glyphPositionsBuffer + index - layoutParameters.startGlyphIndex );
+
+ // Updates the vertical pen's position.
+ penY += -layout.descender;
+
+ // Increase the glyph index.
+ index = nextIndex;
+ } // no ellipsis
+ } // end for() traversing glyphs.
+
+ if( updateCurrentBuffer )
+ {
+ glyphPositions.Insert( glyphPositions.Begin() + layoutParameters.startGlyphIndex,
+ newGlyphPositions.Begin(),
+ newGlyphPositions.End() );
+ glyphPositions.Resize( layoutParameters.totalNumberOfGlyphs );
+
+ newLines.Resize( numberOfLines );
+
+ // Current text's layout size adds only the newly laid-out lines.
+ // Updates the layout size with the previously laid-out lines.
+ UpdateLayoutSize( lines,
+ layoutSize );
+
+ if( 0u != newLines.Count() )
+ {
+ const LineRun& lastLine = *( newLines.End() - 1u );
+
+ const Length characterOffset = lastLine.characterRun.characterIndex + lastLine.characterRun.numberOfCharacters;
+ const Length glyphOffset = lastLine.glyphRun.glyphIndex + lastLine.glyphRun.numberOfGlyphs;
+
+ // Update the indices of the runs before the new laid-out lines are inserted.
+ UpdateLineIndexOffsets( layoutParameters,
+ lines,
+ characterOffset,
+ glyphOffset );
+
+ // Insert the lines.
+ lines.Insert( lines.Begin() + layoutParameters.startLineIndex,
+ newLines.Begin(),
+ newLines.End() );
+ }
+ }
+ else
+ {
+ lines.Resize( numberOfLines );
+ }
+
+ DALI_LOG_INFO( gLogFilter, Debug::Verbose, "<--LayoutText\n\n" );
+
+ return true;
+ }
+
+ void ReLayoutRightToLeftLines( const LayoutParameters& layoutParameters,
+ CharacterIndex startIndex,
+ Length numberOfCharacters,
+ Vector<Vector2>& glyphPositions )
+ {
+ const CharacterIndex lastCharacterIndex = startIndex + numberOfCharacters;
+
+ // Traverses the paragraphs with right to left characters.
+ for( LineIndex lineIndex = 0u; lineIndex < layoutParameters.numberOfBidirectionalInfoRuns; ++lineIndex )
+ {
+ const BidirectionalLineInfoRun& bidiLine = *( layoutParameters.lineBidirectionalInfoRunsBuffer + lineIndex );
+
+ if( startIndex >= bidiLine.characterRun.characterIndex + bidiLine.characterRun.numberOfCharacters )