Layout Engine - Fix for multiline 31/37131/4
authorVictor Cebollada <v.cebollada@samsung.com>
Thu, 19 Mar 2015 13:46:14 +0000 (13:46 +0000)
committerVictor Cebollada <v.cebollada@samsung.com>
Fri, 20 Mar 2015 07:22:11 +0000 (07:22 +0000)
Change-Id: Id630065dc4a600af272f2340796b35ff390f6b26
Signed-off-by: Victor Cebollada <v.cebollada@samsung.com>
dali-toolkit/internal/text/bidirectional-support.cpp
dali-toolkit/internal/text/layouts/layout-engine.cpp
dali-toolkit/internal/text/shaper.cpp

index b9ff99a..6f74f19 100644 (file)
@@ -220,7 +220,7 @@ void ReorderLines( const Vector<BidirectionalParagraphInfoRun>& bidirectionalInf
 
       // Reorders the line.
       bidirectionalSupport.Reorder( paragraphInfo.bidirectionalInfoIndex,
 
       // Reorders the line.
       bidirectionalSupport.Reorder( paragraphInfo.bidirectionalInfoIndex,
-                                    line.characterRun.characterIndex,
+                                    line.characterRun.characterIndex - paragraphInfo.characterRun.characterIndex,
                                     line.characterRun.numberOfCharacters,
                                     lineInfoRun.visualToLogicalMap );
 
                                     line.characterRun.numberOfCharacters,
                                     lineInfoRun.visualToLogicalMap );
 
index 460fb02..4e090e0 100644 (file)
@@ -219,33 +219,30 @@ struct LayoutEngine::Impl
 
       if( TextAbstraction::LINE_MUST_BREAK == lineBreakInfo )
       {
 
       if( TextAbstraction::LINE_MUST_BREAK == lineBreakInfo )
       {
-        if( glyphIndex == lastGlyphIndex )
+        // Must break the line. Update the line layout and return.
+        lineLayout.numberOfCharacters += tmpLineLayout.numberOfCharacters;
+        lineLayout.numberOfGlyphs += tmpLineLayout.numberOfGlyphs;
+        lineLayout.length += tmpLineLayout.length;
+
+        if( 0.f < tmpLineLayout.length )
+        {
+          lineLayout.length += lineLayout.wsLengthEndOfLine;
+
+          lineLayout.wsLengthEndOfLine = tmpLineLayout.wsLengthEndOfLine;
+        }
+        else
         {
         {
-          // Must break the line. Update the line layout and return.
-          lineLayout.numberOfCharacters += tmpLineLayout.numberOfCharacters;
-          lineLayout.numberOfGlyphs += tmpLineLayout.numberOfGlyphs;
-          lineLayout.length += tmpLineLayout.length;
-
-          if( 0.f < tmpLineLayout.length )
-          {
-            lineLayout.length += lineLayout.wsLengthEndOfLine;
-
-            lineLayout.wsLengthEndOfLine = tmpLineLayout.wsLengthEndOfLine;
-          }
-          else
-          {
-            lineLayout.wsLengthEndOfLine += tmpLineLayout.wsLengthEndOfLine;
-          }
-
-          if( tmpLineLayout.height > lineLayout.height )
-          {
-            lineLayout.height = tmpLineLayout.height;
-          }
-
-          if( tmpLineLayout.ascender > lineLayout.ascender )
-          {
-            lineLayout.ascender = tmpLineLayout.ascender;
-          }
+          lineLayout.wsLengthEndOfLine += tmpLineLayout.wsLengthEndOfLine;
+        }
+
+        if( tmpLineLayout.height > lineLayout.height )
+        {
+          lineLayout.height = tmpLineLayout.height;
+        }
+
+        if( tmpLineLayout.ascender > lineLayout.ascender )
+        {
+          lineLayout.ascender = tmpLineLayout.ascender;
         }
 
         tmpLineLayout.numberOfCharacters = 0u;
         }
 
         tmpLineLayout.numberOfCharacters = 0u;
index 55101eb..8e2eed1 100644 (file)
@@ -131,11 +131,17 @@ void ShapeText( const Vector<Character>& text,
       }
     }
 
       }
     }
 
-    // Check if the current index is a white space. Do not want to shape a \n.
+    // Check if the current index is a new paragraph character.
+    // A \n is going to be shaped in order to not to mess the conversion tables.
+    // After the \n character is shaped, the glyph is going to be reset to its
+    // default in order to not to get any metric or font index for it.
+    const bool isNewParagraph = TextAbstraction::IsNewParagraph( *( textBuffer + currentIndex ) );
+
     // The last character is always a must-break even if it's not a \n.
     Length numberOfCharactersToShape = currentIndex - previousIndex;
     // The last character is always a must-break even if it's not a \n.
     Length numberOfCharactersToShape = currentIndex - previousIndex;
-    if( mustBreak && !TextAbstraction::IsWhiteSpace( *( textBuffer + currentIndex ) ) )
+    if( mustBreak )
     {
     {
+      // Add one more character to shape.
       ++numberOfCharactersToShape;
     }
 
       ++numberOfCharactersToShape;
     }
 
@@ -164,6 +170,18 @@ void ShapeText( const Vector<Character>& text,
     shaping.GetGlyphs( glyphsBuffer + glyphIndex,
                        glyphToCharacterMapBuffer + glyphIndex );
 
     shaping.GetGlyphs( glyphsBuffer + glyphIndex,
                        glyphToCharacterMapBuffer + glyphIndex );
 
+    if( isNewParagraph )
+    {
+      // TODO : This is a work around to avoid drawing a square in the
+      //        place of a new line character.
+
+      // If the last character is a \n, it resets the glyph to the default
+      // to avoid getting any metric for it.
+      GlyphInfo& glyph = *( glyphsBuffer + glyphIndex + ( numberOfGlyphs - 1u ) );
+
+      glyph = GlyphInfo();
+    }
+
     // Update indices.
     if( 0u != glyphIndex )
     {
     // Update indices.
     if( 0u != glyphIndex )
     {