Fix wrong cursor position issues in difference horizontal alignment
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / text / layouts / layout-engine.cpp
index 9d1b93d..6e8be71 100755 (executable)
@@ -53,6 +53,11 @@ const float MAX_FLOAT = std::numeric_limits<float>::max();
 const bool RTL = true;
 const float LINE_SPACING= 0.f;
 
+inline bool isEmptyLineAtLast( const Vector<LineRun>& lines, const Vector<LineRun>::Iterator& line )
+{
+  return ( (*line).characterRun.numberOfCharacters == 0 && line + 1u == lines.End() );
+}
+
 } //namespace
 
 /**
@@ -1042,12 +1047,18 @@ struct Engine::Impl
         continue;
       }
 
-      if( line.characterRun.characterIndex >= lastCharacterPlusOne )
+      if( line.characterRun.characterIndex > lastCharacterPlusOne )
       {
         // Do not align lines beyond the last laid-out character.
         break;
       }
 
+      if( line.characterRun.characterIndex == lastCharacterPlusOne && !isEmptyLineAtLast( lines, it ) )
+      {
+        // Do not align lines beyond the last laid-out character unless the line is last and empty.
+        break;
+      }
+
       // Calculate the line's alignment offset accordingly with the align option,
       // the box width, line length, and the paragraph's direction.
       CalculateHorizontalAlignment( size.width,