Fix the incorrect offset of text outline 56/216056/5
authorRichard Huang <r.huang@samsung.com>
Fri, 18 Oct 2019 13:56:18 +0000 (14:56 +0100)
committerRichard Huang <r.huang@samsung.com>
Thu, 24 Oct 2019 14:37:16 +0000 (15:37 +0100)
Change-Id: I1a40cea5ad20308e2e968331a514eb3adc396aa0

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

index 20ea5f7..5b424be 100755 (executable)
@@ -683,6 +683,7 @@ Devel::PixelBuffer Typesetter::CreateImageBuffer( const unsigned int bufferWidth
         // Don't render outline for other styles
         outlineWidth = 0.0f;
       }
+
       if( style != Typesetter::STYLE_UNDERLINE )
       {
         fontClient.CreateBitmap( glyphInfo->fontId,
@@ -693,15 +694,30 @@ Devel::PixelBuffer Typesetter::CreateImageBuffer( const unsigned int bufferWidth
                                  static_cast<int>( outlineWidth ) );
       }
 
-
       // Sets the glyph's bitmap into the bitmap of the whole text.
       if( NULL != glyphData.glyphBitmap.buffer )
       {
+        if ( style == Typesetter::STYLE_OUTLINE )
+        {
+          // Set the position offset for the current glyph
+          glyphData.horizontalOffset -= glyphData.glyphBitmap.outlineOffsetX;
+          glyphData.verticalOffset -= glyphData.glyphBitmap.outlineOffsetY;
+        }
+
+        // Set the buffer of the glyph's bitmap into the final bitmap's buffer
         TypesetGlyph( glyphData,
                       position,
                       &color,
                       style,
                       pixelFormat);
+
+        if ( style == Typesetter::STYLE_OUTLINE )
+        {
+          // Reset the position offset for the next glyph
+          glyphData.horizontalOffset += glyphData.glyphBitmap.outlineOffsetX;
+          glyphData.verticalOffset += glyphData.glyphBitmap.outlineOffsetY;
+        }
+
         // delete the glyphBitmap.buffer as it is now copied into glyphData.bitmapBuffer
         delete []glyphData.glyphBitmap.buffer;
         glyphData.glyphBitmap.buffer = NULL;