- CharacterDirection nextDirection = false;
-
- characterDirection = false;
-
- // Get the bidi direction.
- const BidiDirection bidiDirection = GetBidiCharacterDirection(*(bidirectionalInfo->characterTypes + index));
-
- if(RIGHT_TO_LEFT == bidiDirection)
- {
- characterDirection = true;
- nextDirection = true;
- }
- else if(NEUTRAL == bidiDirection)
- {
- // For neutral characters it check's the next and previous directions.
- // If they are equals set that direction. If they are not, sets the paragraph's direction.
- // If there is no next, sets the paragraph's direction.
- nextDirection = paragraphDirection;
-
- // Look for the next non-neutral character.
- Length nextIndex = index + 1u;
- for(; nextIndex < numberOfCharacters; ++nextIndex)
- {
- BidiDirection nextBidiDirection = GetBidiCharacterDirection(*(bidirectionalInfo->characterTypes + nextIndex));
- if(nextBidiDirection != NEUTRAL)
- {
- nextDirection = RIGHT_TO_LEFT == nextBidiDirection;
- break;
- }
- }
-
- // Calculate the direction for all the neutral characters.
- characterDirection = previousDirection == nextDirection ? previousDirection : paragraphDirection;
-
- // Set the direction to all the neutral characters.
- // The indices from currentIndex + 1u to nextIndex - 1u are neutral characters.
- ++index;
-
- for(; index < nextIndex; ++index)
- {
- CharacterDirection& nextCharacterDirection = *(directions + index);
- nextCharacterDirection = characterDirection;
- }
-
- // Set the direction of the next non-neutral character.
- if(nextIndex < numberOfCharacters)
- {
- *(directions + nextIndex) = nextDirection;
- }
- }