+
+ 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,
+ HorizontalAlignment horizontalAlignment,
+ Vector<LineRun>& lines,
+ float& alignmentOffset )
+ {
+ const CharacterIndex lastCharacterPlusOne = startIndex + numberOfCharacters;
+
+ alignmentOffset = MAX_FLOAT;
+ // Traverse all lines and align the glyphs.
+ for( Vector<LineRun>::Iterator it = lines.Begin(), endIt = lines.End();
+ it != endIt;
+ ++it )
+ {
+ LineRun& line = *it;
+
+ if( line.characterRun.characterIndex < startIndex )
+ {
+ // Do not align lines which have already been aligned.
+ continue;
+ }
+
+ if( line.characterRun.characterIndex >= lastCharacterPlusOne )
+ {
+ // Do not align lines beyond the last laid-out character.
+ break;
+ }
+
+ // Calculate the line's alignment offset accordingly with the align option,
+ // the box width, line length, and the paragraph's direction.
+ CalculateHorizontalAlignment( size.width,
+ horizontalAlignment,
+ line );
+
+ // Updates the alignment offset.
+ alignmentOffset = std::min( alignmentOffset, line.alignmentOffset );