From b2c40cd4b5ef27a4661091919ff2589afc39a155 Mon Sep 17 00:00:00 2001 From: Victor Cebollada Date: Thu, 1 Oct 2015 14:09:32 +0100 Subject: [PATCH] Fix for bidirectional support. * Sets correctly the direction of neutral characters when more than one come together. Change-Id: I1700813a05d482f41f7e8dbfec0643293c42f68a Signed-off-by: Victor Cebollada --- .../bidirectional-support-impl.cpp | 30 ++++++++++++++++++---- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/text/dali/internal/text-abstraction/bidirectional-support-impl.cpp b/text/dali/internal/text-abstraction/bidirectional-support-impl.cpp index 7757849..607a970 100644 --- a/text/dali/internal/text-abstraction/bidirectional-support-impl.cpp +++ b/text/dali/internal/text-abstraction/bidirectional-support-impl.cpp @@ -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; -- 2.7.4