[dali_1.3.45] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / text / layouts / layout-engine.cpp
old mode 100644 (file)
new mode 100755 (executable)
index 4f9a47c..0c3d9df
@@ -281,9 +281,6 @@ struct Engine::Impl
       // Get the line break info for the current character.
       const LineBreakInfo lineBreakInfo = hasCharacters ? *( parameters.lineBreakInfoBuffer + characterLastIndex ) : TextAbstraction::LINE_NO_BREAK;
 
-      // Get the word break info for the current character.
-      const WordBreakInfo wordBreakInfo = *( parameters.wordBreakInfoBuffer + characterLastIndex );
-
       // Increase the number of characters.
       tmpLineLayout.numberOfCharacters += charactersPerGlyph;
 
@@ -466,7 +463,7 @@ struct Engine::Impl
       }
 
       if( isMultiline &&
-          ( TextAbstraction::WORD_BREAK == wordBreakInfo ) )
+          ( TextAbstraction::LINE_ALLOW_BREAK == lineBreakInfo ) )
       {
         oneWordLaidOut = isWordLaidOut;
         DALI_LOG_INFO( gLogFilter, Debug::Verbose, "  One word laid-out\n" );
@@ -1107,7 +1104,9 @@ struct Engine::Impl
               Length numberOfCharacters,
               Text::HorizontalAlignment::Type horizontalAlignment,
               Vector<LineRun>& lines,
-              float& alignmentOffset )
+              float& alignmentOffset,
+              Dali::LayoutDirection::Type layoutDirection,
+              bool matchSystemLanguageDirection )
   {
     const CharacterIndex lastCharacterPlusOne = startIndex + numberOfCharacters;
 
@@ -1135,7 +1134,9 @@ struct Engine::Impl
       // the box width, line length, and the paragraph's direction.
       CalculateHorizontalAlignment( size.width,
                                     horizontalAlignment,
-                                    line );
+                                    line,
+                                    layoutDirection,
+                                    matchSystemLanguageDirection );
 
       // Updates the alignment offset.
       alignmentOffset = std::min( alignmentOffset, line.alignmentOffset );
@@ -1144,16 +1145,24 @@ struct Engine::Impl
 
   void CalculateHorizontalAlignment( float boxWidth,
                                      HorizontalAlignment::Type horizontalAlignment,
-                                     LineRun& line )
+                                     LineRun& line,
+                                     Dali::LayoutDirection::Type layoutDirection,
+                                     bool matchSystemLanguageDirection )
   {
     line.alignmentOffset = 0.f;
-    const bool isRTL = RTL == line.direction;
+    bool isRTL = RTL == line.direction;
     float lineLength = line.width;
-
     HorizontalAlignment::Type alignment = horizontalAlignment;
+
+    // match align for system language direction
+    if( matchSystemLanguageDirection )
+    {
+      isRTL = layoutDirection == LayoutDirection::RIGHT_TO_LEFT;
+    }
+
+    // Swap the alignment type if the line is right to left.
     if( isRTL )
     {
-      // Swap the alignment type if the line is right to left.
       switch( alignment )
       {
         case HorizontalAlignment::BEGIN:
@@ -1172,6 +1181,7 @@ struct Engine::Impl
           break;
         }
       }
+
     }
 
     // Calculate the horizontal line offset.
@@ -1303,14 +1313,18 @@ void Engine::Align( const Size& size,
                     Length numberOfCharacters,
                     Text::HorizontalAlignment::Type horizontalAlignment,
                     Vector<LineRun>& lines,
-                    float& alignmentOffset )
+                    float& alignmentOffset,
+                    Dali::LayoutDirection::Type layoutDirection,
+                    bool matchSystemLanguageDirection )
 {
   mImpl->Align( size,
                 startIndex,
                 numberOfCharacters,
                 horizontalAlignment,
                 lines,
-                alignmentOffset );
+                alignmentOffset,
+                layoutDirection,
+                matchSystemLanguageDirection );
 }
 
 void Engine::SetDefaultLineSpacing( float lineSpacing )