Fix for bidirectional support. 20/48920/1
authorVictor Cebollada <v.cebollada@samsung.com>
Thu, 1 Oct 2015 13:09:32 +0000 (14:09 +0100)
committerVictor Cebollada <v.cebollada@samsung.com>
Thu, 1 Oct 2015 13:28:26 +0000 (14:28 +0100)
* Sets correctly the direction of neutral characters when more than one come together.

Change-Id: I1700813a05d482f41f7e8dbfec0643293c42f68a
Signed-off-by: Victor Cebollada <v.cebollada@samsung.com>
text/dali/internal/text-abstraction/bidirectional-support-impl.cpp

index 7757849..607a970 100644 (file)
@@ -297,15 +297,35 @@ struct BidirectionalSupport::Plugin
         // If there is no next, sets the paragraph's direction.
 
         CharacterDirection nextDirection = paragraphDirection;
-        const Length nextIndex = index + 1u;
-        if( nextIndex < numberOfCharacters )
-        {
-          const BidiDirection nextBidiDirection = GetBidiCharacterDirection( *( bidirectionalInfo->characterTypes + nextIndex ) );
 
-          nextDirection = RIGHT_TO_LEFT == nextBidiDirection;
+        // 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.
+        ++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;
+        }
       }
 
       previousDirection = characterDirection;