+ Vector<BidirectionalLineInfoRun>& bidirectionalLinesInfo = parameters.textModel->mLogicalModel->mBidirectionalLineInfo;
+
+ // Sets the visual to logical map tables needed to reorder the text.
+ ReorderLine( bidirectionalParagraphInfo,
+ bidirectionalLinesInfo,
+ bidiParameters.bidiLineIndex,
+ lineLayout.characterIndex,
+ lineLayout.numberOfCharacters,
+ bidiParameters.paragraphDirection );
+
+ // Recalculate the length of the line and update the layout.
+ const BidirectionalLineInfoRun& bidirectionalLineInfo = *( bidirectionalLinesInfo.Begin() + bidiParameters.bidiLineIndex );
+
+ if( !bidirectionalLineInfo.isIdentity )
+ {
+ float length = 0.f;
+ float whiteSpaceLengthEndOfLine = 0.f;
+ LayoutRightToLeft( parameters,
+ bidirectionalLineInfo,
+ length,
+ whiteSpaceLengthEndOfLine );
+
+ lineLayout.whiteSpaceLengthEndOfLine = whiteSpaceLengthEndOfLine;
+ if( !Equals( length, lineLayout.length ) )
+ {
+ const bool isMultiline = mLayout == MULTI_LINE_BOX;
+
+ if( isMultiline && ( length > parameters.boundingBox.width ) )
+ {
+ if( breakInCharacters || ( isMultiline && ( 0u == currentLineLayout.numberOfGlyphs ) ) )
+ {
+ // The word doesn't fit in one line. It has to be split by character.
+
+ // Remove the last laid out glyph(s) as they doesn't fit.
+ for( GlyphIndex glyphIndex = lineLayout.glyphIndex + lineLayout.numberOfGlyphs - 1u; glyphIndex >= lineLayout.glyphIndex; )
+ {
+ const Length numberOfGLyphsInGroup = GetNumberOfGlyphsOfGroup( glyphIndex,
+ lastGlyphOfParagraphPlusOne,
+ charactersPerGlyphBuffer );
+
+ const Length numberOfCharacters = *( charactersPerGlyphBuffer + glyphIndex + numberOfGLyphsInGroup - 1u );
+
+ lineLayout.numberOfGlyphs -= numberOfGLyphsInGroup;
+ lineLayout.numberOfCharacters -= numberOfCharacters;
+
+ AdjustLayout( parameters,
+ bidiParameters,
+ bidirectionalParagraphInfo,
+ lineLayout );
+
+ if( lineLayout.length < parameters.boundingBox.width )
+ {
+ break;
+ }
+
+ if( glyphIndex < numberOfGLyphsInGroup )
+ {
+ // avoids go under zero for an unsigned int.
+ break;
+ }
+
+ glyphIndex -= numberOfGLyphsInGroup;
+ }
+ }
+ else
+ {
+ lineLayout = currentLineLayout;
+
+ AdjustLayout( parameters,
+ bidiParameters,
+ bidirectionalParagraphInfo,
+ lineLayout );
+ }
+ }
+ else
+ {
+ lineLayout.length = length;
+ }
+ }
+ }