Revert "[3.0] Fix for text-view." 68/55868/2
authortaeyoon <taeyoon0.lee@samsung.com>
Wed, 30 Dec 2015 02:37:29 +0000 (11:37 +0900)
committertaeyoon <taeyoon0.lee@samsung.com>
Fri, 15 Jan 2016 04:39:06 +0000 (13:39 +0900)
This reverts commit 0b6e2ed488d1e0a8e3429f46cfab18e59064d589.

Change-Id: If8e5739bc66402678c039507000d8f7d7de7d51b

dali-toolkit/internal/text/text-view.cpp

index 8d10b2ad8c63009544cfe4d3d666ed8e598da485..ea074fa58c4111914c59c3d25d65d024d0d70620 100644 (file)
@@ -110,155 +110,152 @@ Length View::GetGlyphs( GlyphInfo* glyphs,
         numberOfLaidOutGlyphs = numberOfGlyphs;
       }
 
-      if( 0u < numberOfLaidOutGlyphs )
+      // Retrieve from the visual model the glyphs and positions.
+      mImpl->mVisualModel->GetGlyphs( glyphs,
+                                      glyphIndex,
+                                      numberOfLaidOutGlyphs );
+
+      mImpl->mVisualModel->GetGlyphPositions( glyphPositions,
+                                              glyphIndex,
+                                              numberOfLaidOutGlyphs );
+
+      // Get the lines for the given range of glyphs.
+      // The lines contain the alignment offset which needs to be added to the glyph's position.
+      LineIndex firstLine = 0u;
+      Length numberOfLines = 0u;
+      mImpl->mVisualModel->GetNumberOfLines( glyphIndex,
+                                             numberOfLaidOutGlyphs,
+                                             firstLine,
+                                             numberOfLines );
+
+      Vector<LineRun> lines;
+      lines.Resize( numberOfLines );
+      LineRun* lineBuffer = lines.Begin();
+
+      mImpl->mVisualModel->GetLinesOfGlyphRange( lineBuffer,
+                                                 glyphIndex,
+                                                 numberOfLaidOutGlyphs );
+
+      // Get the first line for the given glyph range.
+      LineIndex lineIndex = firstLine;
+      LineRun* line = lineBuffer + lineIndex;
+
+      // Index of the last glyph of the line.
+      GlyphIndex lastGlyphIndexOfLine = line->glyphRun.glyphIndex + line->glyphRun.numberOfGlyphs - 1u;
+
+      // Add the alignment offset to the glyph's position.
+      for( Length index = 0u; index < numberOfLaidOutGlyphs; ++index )
       {
-        // Retrieve from the visual model the glyphs and positions.
-        mImpl->mVisualModel->GetGlyphs( glyphs,
-                                        glyphIndex,
-                                        numberOfLaidOutGlyphs );
-
-        mImpl->mVisualModel->GetGlyphPositions( glyphPositions,
-                                                glyphIndex,
-                                                numberOfLaidOutGlyphs );
-
-        // Get the lines for the given range of glyphs.
-        // The lines contain the alignment offset which needs to be added to the glyph's position.
-        LineIndex firstLine = 0u;
-        Length numberOfLines = 0u;
-        mImpl->mVisualModel->GetNumberOfLines( glyphIndex,
-                                               numberOfLaidOutGlyphs,
-                                               firstLine,
-                                               numberOfLines );
-
-        Vector<LineRun> lines;
-        lines.Resize( numberOfLines );
-        LineRun* lineBuffer = lines.Begin();
-
-        mImpl->mVisualModel->GetLinesOfGlyphRange( lineBuffer,
-                                                   glyphIndex,
-                                                   numberOfLaidOutGlyphs );
-
-        // Get the first line for the given glyph range.
-        LineIndex lineIndex = firstLine;
-        LineRun* line = lineBuffer + lineIndex;
-
-        // Index of the last glyph of the line.
-        GlyphIndex lastGlyphIndexOfLine = line->glyphRun.glyphIndex + line->glyphRun.numberOfGlyphs - 1u;
-
-        // Add the alignment offset to the glyph's position.
-        for( Length index = 0u; index < numberOfLaidOutGlyphs; ++index )
+        ( *( glyphPositions + index ) ).x += line->alignmentOffset;
+
+        if( lastGlyphIndexOfLine == index )
         {
-          ( *( glyphPositions + index ) ).x += line->alignmentOffset;
+          // Get the next line.
+          ++lineIndex;
 
-          if( lastGlyphIndexOfLine == index )
+          if( lineIndex < numberOfLines )
           {
-            // Get the next line.
-            ++lineIndex;
-
-            if( lineIndex < numberOfLines )
-            {
-              line = lineBuffer + lineIndex;
-              lastGlyphIndexOfLine = line->glyphRun.glyphIndex + line->glyphRun.numberOfGlyphs - 1u;
-            }
+            line = lineBuffer + lineIndex;
+            lastGlyphIndexOfLine = line->glyphRun.glyphIndex + line->glyphRun.numberOfGlyphs - 1u;
           }
         }
+      }
 
-        if( 1u == numberOfLaidOutGlyphs )
-        {
-          // not a point try to do ellipsis with only one laid out character.
-          return numberOfLaidOutGlyphs;
-        }
+      if( 1u == numberOfLaidOutGlyphs )
+      {
+        // not a point try to do ellipsis with only one laid out character.
+        return numberOfLaidOutGlyphs;
+      }
 
-        if( lastLine.ellipsis )
+      if( lastLine.ellipsis )
+      {
+        // firstPenX, penY and firstPenSet are used to position the ellipsis glyph if needed.
+        float firstPenX = 0.f; // Used if rtl text is elided.
+        float penY = 0.f;
+        bool firstPenSet = false;
+
+        // Add the ellipsis glyph.
+        bool inserted = false;
+        float removedGlypsWidth = 0.f;
+        Length numberOfRemovedGlyphs = 0u;
+        GlyphIndex index = numberOfLaidOutGlyphs - 1u;
+
+        // The ellipsis glyph has to fit in the place where the last glyph(s) is(are) removed.
+        while( !inserted )
         {
-          // firstPenX, penY and firstPenSet are used to position the ellipsis glyph if needed.
-          float firstPenX = 0.f; // Used if rtl text is elided.
-          float penY = 0.f;
-          bool firstPenSet = false;
-
-          // Add the ellipsis glyph.
-          bool inserted = false;
-          float removedGlypsWidth = 0.f;
-          Length numberOfRemovedGlyphs = 0u;
-          GlyphIndex index = numberOfLaidOutGlyphs - 1u;
-
-          // The ellipsis glyph has to fit in the place where the last glyph(s) is(are) removed.
-          while( !inserted )
+          const GlyphInfo& glyphToRemove = *( glyphs + index );
+
+          if( 0u != glyphToRemove.fontId )
           {
-            const GlyphInfo& glyphToRemove = *( glyphs + index );
+            // i.e. The font id of the glyph shaped from the '\n' character is zero.
+
+            // Need to reshape the glyph as the font may be different in size.
+            const GlyphInfo& ellipsisGlyph = mImpl->mFontClient.GetEllipsisGlyph( mImpl->mFontClient.GetPointSize( glyphToRemove.fontId ) );
 
-            if( 0u != glyphToRemove.fontId )
+            if( !firstPenSet )
             {
-              // i.e. The font id of the glyph shaped from the '\n' character is zero.
+              const Vector2& position = *( glyphPositions + index );
 
-              // Need to reshape the glyph as the font may be different in size.
-              const GlyphInfo& ellipsisGlyph = mImpl->mFontClient.GetEllipsisGlyph( mImpl->mFontClient.GetPointSize( glyphToRemove.fontId ) );
+              // Calculates the penY of the current line. It will be used to position the ellipsis glyph.
+              penY = position.y + glyphToRemove.yBearing;
 
-              if( !firstPenSet )
+              // Calculates the first penX which will be used if rtl text is elided.
+              firstPenX = position.x - glyphToRemove.xBearing;
+              if( firstPenX < -ellipsisGlyph.xBearing )
               {
-                const Vector2& position = *( glyphPositions + index );
-
-                // Calculates the penY of the current line. It will be used to position the ellipsis glyph.
-                penY = position.y + glyphToRemove.yBearing;
-
-                // Calculates the first penX which will be used if rtl text is elided.
-                firstPenX = position.x - glyphToRemove.xBearing;
-                if( firstPenX < -ellipsisGlyph.xBearing )
-                {
-                  // Avoids to exceed the bounding box when rtl text is elided.
-                  firstPenX = -ellipsisGlyph.xBearing;
-                }
-
-                removedGlypsWidth = -ellipsisGlyph.xBearing;
-
-                firstPenSet = true;
+                // Avoids to exceed the bounding box when rtl text is elided.
+                firstPenX = -ellipsisGlyph.xBearing;
               }
 
-              removedGlypsWidth += std::min( glyphToRemove.advance, ( glyphToRemove.xBearing + glyphToRemove.width ) );
+              removedGlypsWidth = -ellipsisGlyph.xBearing;
 
-              // Calculate the width of the ellipsis glyph and check if it fits.
-              const float ellipsisGlyphWidth = ellipsisGlyph.width + ellipsisGlyph.xBearing;
-              if( ellipsisGlyphWidth < removedGlypsWidth )
-              {
-                GlyphInfo& glyphInfo = *( glyphs + index );
-                Vector2& position = *( glyphPositions + index );
-                position.x -= ( 0.f > glyphInfo.xBearing ) ? glyphInfo.xBearing : 0.f;
+              firstPenSet = true;
+            }
 
-                // Replace the glyph by the ellipsis glyph.
-                glyphInfo = ellipsisGlyph;
+            removedGlypsWidth += std::min( glyphToRemove.advance, ( glyphToRemove.xBearing + glyphToRemove.width ) );
 
-                // Change the 'x' and 'y' position of the ellipsis glyph.
+            // Calculate the width of the ellipsis glyph and check if it fits.
+            const float ellipsisGlyphWidth = ellipsisGlyph.width + ellipsisGlyph.xBearing;
+            if( ellipsisGlyphWidth < removedGlypsWidth )
+            {
+              GlyphInfo& glyphInfo = *( glyphs + index );
+              Vector2& position = *( glyphPositions + index );
+              position.x -= ( 0.f > glyphInfo.xBearing ) ? glyphInfo.xBearing : 0.f;
 
-                if( position.x > firstPenX )
-                {
-                  position.x = firstPenX + removedGlypsWidth - ellipsisGlyphWidth;
-                }
+              // Replace the glyph by the ellipsis glyph.
+              glyphInfo = ellipsisGlyph;
 
-                position.x += ellipsisGlyph.xBearing;
-                position.y = penY - ellipsisGlyph.yBearing;
+              // Change the 'x' and 'y' position of the ellipsis glyph.
 
-                inserted = true;
+              if( position.x > firstPenX )
+              {
+                position.x = firstPenX + removedGlypsWidth - ellipsisGlyphWidth;
               }
+
+              position.x += ellipsisGlyph.xBearing;
+              position.y = penY - ellipsisGlyph.yBearing;
+
+              inserted = true;
             }
+          }
 
-            if( !inserted )
+          if( !inserted )
+          {
+            if( index > 0u )
             {
-              if( index > 0u )
-              {
-                --index;
-              }
-              else
-              {
-                // No space for the ellipsis.
-                inserted = true;
-              }
-              ++numberOfRemovedGlyphs;
+              --index;
             }
+            else
+            {
+              // No space for the ellipsis.
+              inserted = true;
+            }
+            ++numberOfRemovedGlyphs;
           }
-
-          // 'Removes' all the glyphs after the ellipsis glyph.
-          numberOfLaidOutGlyphs -= numberOfRemovedGlyphs;
         }
+
+        // 'Removes' all the glyphs after the ellipsis glyph.
+        numberOfLaidOutGlyphs -= numberOfRemovedGlyphs;
       }
     }
   }