+ if(updateCurrentBuffer)
+ {
+ newDirections.Resize(numberOfCharacters);
+ directionsBuffer = newDirections.Begin();
+ }
+ else
+ {
+ directionsBuffer = directions.Begin();
+ }
+
+ const CharacterIndex lastCharacter = startIndex + numberOfCharacters;
+ CharacterIndex index = startIndex;
+
+ for(Vector<BidirectionalParagraphInfoRun>::ConstIterator it = bidirectionalInfo.Begin(),
+ endIt = bidirectionalInfo.End();
+ it != endIt;
+ ++it)
+ {
+ const BidirectionalParagraphInfoRun& paragraph = *it;
+
+ if(index >= paragraph.characterRun.characterIndex + paragraph.characterRun.numberOfCharacters)
+ {
+ // Skip the paragraph as it has already been processed.
+ continue;
+ }
+
+ if(lastCharacter <= paragraph.characterRun.characterIndex)
+ {
+ // Do not get the character directions beyond startIndex + numberOfCharacters.
+ break;
+ }
+
+ // Set the directions of any previous left to right characters.
+ const Length numberOfLeftToRightCharacters = paragraph.characterRun.characterIndex - index;
+ if(numberOfLeftToRightCharacters > 0u)
+ {
+ memset(directionsBuffer + index - startIndex, false, numberOfLeftToRightCharacters * sizeof(bool));
+ }
+
+ // Set the directions of the bidirectional text.
+ bidirectionalSupport.GetCharactersDirection(paragraph.bidirectionalInfoIndex,
+ directionsBuffer + paragraph.characterRun.characterIndex - startIndex,
+ paragraph.characterRun.numberOfCharacters);
+
+ // Update the index.
+ index += paragraph.characterRun.numberOfCharacters + numberOfLeftToRightCharacters;
+ }
+
+ // Fills with left to right those paragraphs without right to left characters.
+ memset(directionsBuffer + index - startIndex, false, (lastCharacter - index) * sizeof(bool));
+
+ // If the direction info is updated, it needs to be inserted in the model.
+ if(updateCurrentBuffer)
+ {
+ // Insert the directions in the given buffer.
+ directions.Insert(directions.Begin() + startIndex,
+ newDirections.Begin(),
+ newDirections.End());
+ directions.Resize(totalNumberOfCharacters);
+ }