// EXTERNAL INCLUDES
#include <memory.h>
#include <fribidi/fribidi.h>
+#include <dali/integration-api/debug.h>
namespace Dali
{
switch( characterDirection )
{
case FRIBIDI_TYPE_LTR: // Left-To-Right letter.
- case FRIBIDI_TYPE_EN: // European Numeral.
- case FRIBIDI_TYPE_AN: // Arabic Numeral.
- case FRIBIDI_TYPE_ES: // European number Separator.
- case FRIBIDI_TYPE_ET: // European number Terminator.
{
return LEFT_TO_RIGHT;
}
- case FRIBIDI_TYPE_RTL: // Right-To-Left letter.
case FRIBIDI_TYPE_AL: // Arabic Letter.
+ case FRIBIDI_TYPE_RTL: // Right-To-Left letter.
{
return RIGHT_TO_LEFT;
}
+ case FRIBIDI_TYPE_AN: // Arabic Numeral.
+ case FRIBIDI_TYPE_ES: // European number Separator.
+ case FRIBIDI_TYPE_ET: // European number Terminator.
+ case FRIBIDI_TYPE_EN: // European Numeral.
+ default :
+ {
+ return NEUTRAL;
+ }
}
-
- return NEUTRAL;
}
}
}
BidiInfoIndex CreateInfo( const Character* const paragraph,
- Length numberOfCharacters )
+ Length numberOfCharacters,
+ bool matchSystemLanguageDirection,
+ LayoutDirection::Type layoutDirection )
{
// Reserve memory for the paragraph's bidirectional info.
BidirectionalInfo* bidirectionalInfo = new BidirectionalInfo();
fribidi_get_bidi_types( paragraph, numberOfCharacters, bidirectionalInfo->characterTypes );
// Retrieve the paragraph's direction.
- bidirectionalInfo->paragraphDirection = fribidi_get_par_direction( bidirectionalInfo->characterTypes, numberOfCharacters );
+ bidirectionalInfo->paragraphDirection = matchSystemLanguageDirection == true ?
+ ( layoutDirection == LayoutDirection::RIGHT_TO_LEFT ? FRIBIDI_PAR_RTL : FRIBIDI_PAR_LTR ) :
+ ( fribidi_get_par_direction( bidirectionalInfo->characterTypes, numberOfCharacters ) );
// Retrieve the embedding levels.
- fribidi_get_par_embedding_levels( bidirectionalInfo->characterTypes, numberOfCharacters, &bidirectionalInfo->paragraphDirection, bidirectionalInfo->embeddedLevels );
+ if (fribidi_get_par_embedding_levels( bidirectionalInfo->characterTypes, numberOfCharacters, &bidirectionalInfo->paragraphDirection, bidirectionalInfo->embeddedLevels ) == 0)
+ {
+ free( bidirectionalInfo->characterTypes );
+ delete bidirectionalInfo;
+ return 0;
+ }
// Store the bidirectional info and return the index.
BidiInfoIndex index = 0u;
memcpy( embeddedLevels, bidirectionalInfo->embeddedLevels + firstCharacterIndex, embeddedLevelsSize );
// Reorder the line.
- fribidi_reorder_line( flags,
- bidirectionalInfo->characterTypes + firstCharacterIndex,
- numberOfCharacters,
- 0u,
- bidirectionalInfo->paragraphDirection,
- embeddedLevels,
- NULL,
- reinterpret_cast<FriBidiStrIndex*>( visualToLogicalMap ) );
+ if (fribidi_reorder_line( flags,
+ bidirectionalInfo->characterTypes + firstCharacterIndex,
+ numberOfCharacters,
+ 0u,
+ bidirectionalInfo->paragraphDirection,
+ embeddedLevels,
+ NULL,
+ reinterpret_cast<FriBidiStrIndex*>( visualToLogicalMap ) ) == 0)
+ {
+ DALI_LOG_ERROR("fribidi_reorder_line is failed\n");
+ }
// Free resources.
free( embeddedLevels );
for( CharacterIndex index = 0u; index < numberOfCharacters; ++index )
{
CharacterDirection& characterDirection = *( directions + index );
+ CharacterDirection nextDirection = false;
+
characterDirection = false;
// Get the bidi direction.
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.
-
- CharacterDirection nextDirection = paragraphDirection;
+ nextDirection = paragraphDirection;
// Look for the next non-neutral character.
Length nextIndex = index + 1u;
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 );
}
}
- previousDirection = characterDirection;
+ previousDirection = nextDirection;
}
}
}
BidiInfoIndex BidirectionalSupport::CreateInfo( const Character* const paragraph,
- Length numberOfCharacters )
+ Length numberOfCharacters,
+ bool matchSystemLanguageDirection,
+ Dali::LayoutDirection::Type layoutDirection )
{
CreatePlugin();
return mPlugin->CreateInfo( paragraph,
- numberOfCharacters );
+ numberOfCharacters,
+ matchSystemLanguageDirection,
+ layoutDirection );
}
void BidirectionalSupport::DestroyInfo( BidiInfoIndex bidiInfoIndex )