- const LineRun& line = *it;
-
- // 1) Get the paragrap's direction.
- bool paragraphDirection = false;
-
- // Check if there is any right to left line.
- if( ( NULL != layoutParameters.lineBidirectionalInfoRunsBuffer ) &&
- ( bidiLineIndex < layoutParameters.numberOfBidirectionalInfoRuns ) )
- {
- const BidirectionalLineInfoRun* bidiLine = layoutParameters.lineBidirectionalInfoRunsBuffer + bidiLineIndex;
-
- // Get the right to left line that match with current line.
- while( ( line.characterRun.characterIndex > bidiLine->characterRun.characterIndex ) &&
- ( bidiLineIndex < layoutParameters.numberOfBidirectionalInfoRuns ) )
- {
- ++bidiLineIndex;
- bidiLine = layoutParameters.lineBidirectionalInfoRunsBuffer + bidiLineIndex;
- }
-
- if( line.characterRun.characterIndex == bidiLine->characterRun.characterIndex )
- {
- paragraphDirection = bidiLine->direction;
- }
- }
-
- // 2) Calculate the alignment offset accordingly with the align option,
- // the box width, line length, and the paragraphs direction.
- float alignOffset = CalculateHorizontalAlignment( layoutSize.width,
- line.width,
- line.extraLength,
- paragraphDirection );
-
- // 3) Traverse all glyphs and update the 'x' position.
- for( GlyphIndex index = line.glyphIndex,
- endIndex = line.glyphIndex + line.numberOfGlyphs;
- index < endIndex;
- ++index )
- {
- Vector2& position = *( glyphPositionsBuffer + index );
-
- position.x += alignOffset;
- }
+ LineRun& line = *it;
+ const bool isLastLine = lines.End() == it + 1u;
+
+ // Calculate the alignment offset accordingly with the align option,
+ // the box width, line length, and the paragraphs direction.
+ CalculateHorizontalAlignment( layoutSize.width,
+ line,
+ isLastLine );