- tmpLineLayout.numberOfCharacters = 0u;
- tmpLineLayout.numberOfGlyphs = 0u;
- tmpLineLayout.length = 0.f;
- tmpLineLayout.widthAdvanceDiff = 0.f;
- tmpLineLayout.wsLengthEndOfLine = 0.f;
- tmpLineLayout.ascender = 0.f;
- tmpLineLayout.descender = MAX_FLOAT;
-
- FontId lastFontId = 0u;
+
+ const bool isMultiline = mLayout == MULTI_LINE_BOX;
+ const bool isWordLaidOut = parameters.lineWrapMode == Text::LineWrap::WORD;
+
+ // The last glyph to be laid-out.
+ const GlyphIndex lastGlyphOfParagraphPlusOne = parameters.startGlyphIndex + parameters.numberOfGlyphs;
+
+ // If the first glyph has a negative bearing its absolute value needs to be added to the line length.
+ // In the case the line starts with a right to left character, if the width is longer than the advance,
+ // the difference needs to be added to the line length.
+
+ // Check whether the first glyph comes from a character that is shaped in multiple glyphs.
+ const Length numberOfGLyphsInGroup = GetNumberOfGlyphsOfGroup( lineLayout.glyphIndex,
+ lastGlyphOfParagraphPlusOne,
+ parameters.charactersPerGlyphBuffer );
+
+ GlyphMetrics glyphMetrics;
+ GetGlyphsMetrics( lineLayout.glyphIndex,
+ numberOfGLyphsInGroup,
+ glyphMetrics,
+ parameters.glyphsBuffer,
+ mMetrics );
+
+ // Set the direction of the first character of the line.
+ lineLayout.characterIndex = *( parameters.glyphsToCharactersBuffer + lineLayout.glyphIndex );
+ const CharacterDirection firstCharacterDirection = ( NULL == parameters.characterDirectionBuffer ) ? false : *( parameters.characterDirectionBuffer + lineLayout.characterIndex );
+ CharacterDirection previousCharacterDirection = firstCharacterDirection;
+
+ const float extraWidth = glyphMetrics.xBearing + glyphMetrics.width - glyphMetrics.advance;
+ float tmpExtraWidth = ( 0.f < extraWidth ) ? extraWidth : 0.f;
+
+ float tmpExtraBearing = ( 0.f > glyphMetrics.xBearing ) ? -glyphMetrics.xBearing : 0.f;
+
+ tmpLineLayout.length += mCursorWidth; // Added to give some space to the cursor.
+
+ // Calculate the line height if there is no characters.
+ FontId lastFontId = glyphMetrics.fontId;
+ UpdateLineHeight( lastFontId, tmpLineLayout );
+
+ bool oneWordLaidOut = false;
+