Fix strikethrough coloring for Textlabel 08/270408/1
authorabdullah <abdullahhasan10@gmail.com>
Tue, 1 Feb 2022 12:23:42 +0000 (14:23 +0200)
committerabdullah <abdullahhasan10@gmail.com>
Tue, 1 Feb 2022 12:23:42 +0000 (14:23 +0200)
Change-Id: If7518092f6e652d5cafa7ed7c8de380e23941c6f

automated-tests/src/dali-toolkit-internal/utc-Dali-TextLabel-internal.cpp
dali-toolkit/internal/text/rendering/text-typesetter.cpp

index 5af84d4..ba067f6 100644 (file)
@@ -227,7 +227,7 @@ int UtcDaliTextLabelMarkupStrikethrough(void)
 
   application.GetScene().Add(textLabel);
 
-  textLabel.SetProperty(TextLabel::Property::TEXT, "<s>ABC</s>EF<s color='red'>GH</s>");
+  textLabel.SetProperty(TextLabel::Property::TEXT, "<s color='red'>ABC</s>EF<s color='green'>GH</s>");
   textLabel.SetProperty(TextLabel ::Property::ENABLE_MARKUP, true);
 
   application.SendNotification();
@@ -247,12 +247,18 @@ int UtcDaliTextLabelMarkupStrikethrough(void)
   //ABC have strikethrough
   DALI_TEST_EQUALS(strikethroughRuns[0u].glyphRun.glyphIndex, 0u, TEST_LOCATION);
   DALI_TEST_EQUALS(strikethroughRuns[0u].glyphRun.numberOfGlyphs, 3u, TEST_LOCATION);
-  DALI_TEST_CHECK(!strikethroughRuns[0u].isColorSet);
+  DALI_TEST_CHECK(strikethroughRuns[0u].isColorSet);
+  DALI_TEST_EQUALS(strikethroughRuns[0u].color.r, 1u, TEST_LOCATION);
+  DALI_TEST_EQUALS(strikethroughRuns[0u].color.g, 0u, TEST_LOCATION);
+  DALI_TEST_EQUALS(strikethroughRuns[0u].color.b, 0u, TEST_LOCATION);
 
   //GH have strikethrough
   DALI_TEST_EQUALS(strikethroughRuns[1u].glyphRun.glyphIndex, 5u, TEST_LOCATION);
   DALI_TEST_EQUALS(strikethroughRuns[1u].glyphRun.numberOfGlyphs, 2u, TEST_LOCATION);
   DALI_TEST_CHECK(strikethroughRuns[1u].isColorSet);
+  DALI_TEST_EQUALS(strikethroughRuns[1u].color.r, 0u, TEST_LOCATION);
+  DALI_TEST_EQUALS(strikethroughRuns[1u].color.g, 1u, TEST_LOCATION);
+  DALI_TEST_EQUALS(strikethroughRuns[1u].color.b, 0u, TEST_LOCATION);
 
   END_TEST;
 }
index 2e01c18..96088b5 100644 (file)
@@ -1224,7 +1224,7 @@ Devel::PixelBuffer Typesetter::CreateImageBuffer(const unsigned int bufferWidth,
     {
       //TODO : The currently implemented strikethrough creates a strikethrough on the line level. We need to create different strikethroughs the case of glyphs with different sizes.
       strikethroughStartingYPosition = (glyphData.verticalOffset + baseline + currentUnderlinePosition) - ((line.ascender) * HALF); // Since Free Type font doesn't contain the strikethrough-position property, strikethrough position will be calculated by moving the underline position upwards by half the value of the line height.
-      DrawStrikethrough(strikethroughColor, bufferWidth, bufferHeight, glyphData, baseline, line, maxStrikethroughThickness, lineExtentLeft, lineExtentRight, strikethroughStartingYPosition);
+      DrawStrikethrough(currentStrikethroughColor, bufferWidth, bufferHeight, glyphData, baseline, line, maxStrikethroughThickness, lineExtentLeft, lineExtentRight, strikethroughStartingYPosition);
     }
 
     // Increases the vertical offset with the line's descender.