+ // 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 )
+ {
+ // Do not reorder the line if it has been already reordered.
+ continue;
+ }
+
+ if( bidiLine.characterRun.characterIndex >= lastCharacterIndex )
+ {
+ // Do not reorder the lines after the last requested character.
+ break;
+ }
+
+ const CharacterIndex characterVisualIndex = bidiLine.characterRun.characterIndex + *bidiLine.visualToLogicalMap;
+ const GlyphInfo& glyph = *( layoutParameters.glyphsBuffer + *( layoutParameters.charactersToGlyphsBuffer + characterVisualIndex ) );
+
+ float penX = ( 0.f > glyph.xBearing ) ? -glyph.xBearing : 0.f;
+
+ Vector2* glyphPositionsBuffer = glyphPositions.Begin();
+
+ // Traverses the characters of the right to left paragraph.
+ for( CharacterIndex characterLogicalIndex = 0u;
+ characterLogicalIndex < bidiLine.characterRun.numberOfCharacters;
+ ++characterLogicalIndex )
+ {
+ // Convert the character in the logical order into the character in the visual order.
+ const CharacterIndex characterVisualIndex = bidiLine.characterRun.characterIndex + *( bidiLine.visualToLogicalMap + characterLogicalIndex );
+
+ // Get the number of glyphs of the character.
+ const Length numberOfGlyphs = *( layoutParameters.glyphsPerCharacterBuffer + characterVisualIndex );
+
+ for( GlyphIndex index = 0u; index < numberOfGlyphs; ++index )
+ {
+ // Convert the character in the visual order into the glyph in the visual order.
+ const GlyphIndex glyphIndex = *( layoutParameters.charactersToGlyphsBuffer + characterVisualIndex ) + index;
+
+ DALI_ASSERT_DEBUG( 0u <= glyphIndex && glyphIndex < layoutParameters.totalNumberOfGlyphs );
+
+ const GlyphInfo& glyph = *( layoutParameters.glyphsBuffer + glyphIndex );
+ Vector2& position = *( glyphPositionsBuffer + glyphIndex );
+
+ position.x = penX + glyph.xBearing;
+ penX += glyph.advance;
+ }
+ }
+ }
+ }
+
+ void Align( const Size& size,
+ CharacterIndex startIndex,
+ Length numberOfCharacters,
+ Vector<LineRun>& lines )
+ {
+ const CharacterIndex lastCharacterPlusOne = startIndex + numberOfCharacters;
+
+ // Traverse all lines and align the glyphs.
+ for( Vector<LineRun>::Iterator it = lines.Begin(), endIt = lines.End();
+ it != endIt;
+ ++it )