Fixed SVACE error in text-typesetter.cpp 53/258153/3
authorAdeel Kazmi <adeel.kazmi@samsung.com>
Tue, 11 May 2021 09:01:33 +0000 (10:01 +0100)
committerAdeel Kazmi <adeel.kazmi@samsung.com>
Tue, 11 May 2021 12:09:53 +0000 (13:09 +0100)
Change-Id: I98d6c357528eba5f87c272c48e3827005dc4b674

dali-toolkit/internal/text/rendering/text-typesetter.cpp

index 40d96b8..83d67d5 100644 (file)
@@ -599,7 +599,6 @@ PixelData Typesetter::Render(const Vector2& size, Toolkit::DevelText::TextDirect
     // Markup-Processor
 
     imageBuffer = ApplyMarkupProcessorOnPixelBuffer(imageBuffer, bufferWidth, bufferHeight, ignoreHorizontalAlignment, pixelFormat, penX, penY);
-
   }
 
   // Create the final PixelData for the combined image buffer
@@ -852,15 +851,18 @@ Devel::PixelBuffer Typesetter::CreateImageBuffer(const unsigned int bufferWidth,
         glyphData.glyphBitmap.buffer = NULL;
       }
 
-      while((hyphenIndex < hyphensCount) && (glyphIndex > hyphenIndices[hyphenIndex]))
+      if(hyphenIndices)
       {
-        hyphenIndex++;
-      }
+        while((hyphenIndex < hyphensCount) && (glyphIndex > hyphenIndices[hyphenIndex]))
+        {
+          hyphenIndex++;
+        }
 
-      addHyphen = ((hyphenIndex < hyphensCount) && hyphenIndices && ((glyphIndex + 1) == hyphenIndices[hyphenIndex]));
-      if(addHyphen)
-      {
-        glyphIndex--;
+        addHyphen = ((hyphenIndex < hyphensCount) && ((glyphIndex + 1) == hyphenIndices[hyphenIndex]));
+        if(addHyphen)
+        {
+          glyphIndex--;
+        }
       }
     }
 
@@ -947,44 +949,44 @@ Devel::PixelBuffer Typesetter::CombineImageBuffer(Devel::PixelBuffer topPixelBuf
 
 Devel::PixelBuffer Typesetter::ApplyMarkupProcessorOnPixelBuffer(Devel::PixelBuffer topPixelBuffer, const unsigned int bufferWidth, const unsigned int bufferHeight, bool ignoreHorizontalAlignment, Pixel::Format pixelFormat, int horizontalOffset, int verticalOffset)
 {
-    // Apply the markup-Processor if enabled
-    const bool markupProcessorEnabled = mModel->IsMarkupProcessorEnabled();
-    if(markupProcessorEnabled)
+  // Apply the markup-Processor if enabled
+  const bool markupProcessorEnabled = mModel->IsMarkupProcessorEnabled();
+  if(markupProcessorEnabled)
+  {
+    // Underline-tags (this is for Markup case)
+    // Get the underline runs.
+    const Length     numberOfUnderlineRuns = mModel->GetNumberOfUnderlineRuns();
+    Vector<GlyphRun> underlineRuns;
+    underlineRuns.Resize(numberOfUnderlineRuns);
+    mModel->GetUnderlineRuns(underlineRuns.Begin(), 0u, numberOfUnderlineRuns);
+
+    // Iterate on the consecutive underlined glyph run and connect them into one chunk of underlined characters.
+    Vector<GlyphRun>::ConstIterator itGlyphRun    = underlineRuns.Begin();
+    Vector<GlyphRun>::ConstIterator endItGlyphRun = underlineRuns.End();
+    GlyphIndex                      startGlyphIndex, endGlyphIndex;
+
+    //The outer loop to iterate on the separated chunks of underlined glyph runs
+    while(itGlyphRun != endItGlyphRun)
     {
-      // Underline-tags (this is for Markup case)
-      // Get the underline runs.
-      const Length     numberOfUnderlineRuns = mModel->GetNumberOfUnderlineRuns();
-      Vector<GlyphRun> underlineRuns;
-      underlineRuns.Resize(numberOfUnderlineRuns);
-      mModel->GetUnderlineRuns(underlineRuns.Begin(), 0u, numberOfUnderlineRuns);
-
-      // Iterate on the consecutive underlined glyph run and connect them into one chunk of underlined characters.
-      Vector<GlyphRun>::ConstIterator itGlyphRun       = underlineRuns.Begin();
-      Vector<GlyphRun>::ConstIterator endItGlyphRun    = underlineRuns.End();
-      GlyphIndex startGlyphIndex, endGlyphIndex;
-
-      //The outer loop to iterate on the separated chunks of underlined glyph runs
-      while(itGlyphRun != endItGlyphRun)
+      startGlyphIndex = itGlyphRun->glyphIndex;
+      endGlyphIndex   = startGlyphIndex;
+      //The inner loop to make a connected underline for the consecutive characters
+      do
       {
-        startGlyphIndex = itGlyphRun->glyphIndex;
-        endGlyphIndex = startGlyphIndex;
-        //The inner loop to make a connected underline for the consecutive characters
-        do
-        {
-          endGlyphIndex += itGlyphRun->numberOfGlyphs;
-          itGlyphRun++;
-        } while(itGlyphRun != endItGlyphRun && itGlyphRun->glyphIndex == endGlyphIndex);
+        endGlyphIndex += itGlyphRun->numberOfGlyphs;
+        itGlyphRun++;
+      } while(itGlyphRun != endItGlyphRun && itGlyphRun->glyphIndex == endGlyphIndex);
 
-        endGlyphIndex--;
+      endGlyphIndex--;
 
-        // Create the image buffer for underline
-        Devel::PixelBuffer underlineImageBuffer = CreateImageBuffer(bufferWidth, bufferHeight, Typesetter::STYLE_UNDERLINE, ignoreHorizontalAlignment, pixelFormat, horizontalOffset, verticalOffset, startGlyphIndex, endGlyphIndex);
-        // Combine the two buffers
-        topPixelBuffer = CombineImageBuffer(topPixelBuffer, underlineImageBuffer, bufferWidth, bufferHeight);
-      }
+      // Create the image buffer for underline
+      Devel::PixelBuffer underlineImageBuffer = CreateImageBuffer(bufferWidth, bufferHeight, Typesetter::STYLE_UNDERLINE, ignoreHorizontalAlignment, pixelFormat, horizontalOffset, verticalOffset, startGlyphIndex, endGlyphIndex);
+      // Combine the two buffers
+      topPixelBuffer = CombineImageBuffer(topPixelBuffer, underlineImageBuffer, bufferWidth, bufferHeight);
     }
+  }
 
-    return topPixelBuffer;
+  return topPixelBuffer;
 }
 
 Typesetter::Typesetter(const ModelInterface* const model)