Fix applying Markup Bold caused double bolding 80/318780/5
authorANZ1217 <chihun.jeong@samsung.com>
Tue, 8 Oct 2024 08:35:02 +0000 (17:35 +0900)
committerANZ1217 <chihun.jeong@samsung.com>
Wed, 16 Oct 2024 06:17:12 +0000 (15:17 +0900)
Change-Id: I7344475f64fa749d50404e3795bf67566607fdfa

automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Shaping.cpp
automated-tests/src/dali-toolkit-internal/utc-Dali-Text-TextSpannable.cpp
dali-toolkit/internal/text/multi-language-support-impl.cpp

index 614162c987c496266be6d7bcb89db613221167db..11075b6af770a838b944041a5ca8cc5644a260e0 100755 (executable)
@@ -773,17 +773,17 @@ int UtcDaliTextSoftwareStyling(void)
 
   struct GlyphInfoData glyphs01[] =
     {
-      {4u, 38u, 0.f, 0.f, 0.f, 0.f, 11.f, 0.f, true, true},
-      {4u, 39u, 0.f, 0.f, 0.f, 0.f, 10.f, 0.f, true, true},
-      {4u, 40u, 0.f, 0.f, 0.f, 0.f, 10.f, 0.f, true, true},
-      {4u, 41u, 0.f, 0.f, 0.f, 0.f, 10.f, 0.f, true, true},
+      {4u, 38u, 0.f, 0.f, 0.f, 0.f, 11.f, 0.f, true, false},
+      {4u, 39u, 0.f, 0.f, 0.f, 0.f, 10.f, 0.f, true, false},
+      {4u, 40u, 0.f, 0.f, 0.f, 0.f, 10.f, 0.f, true, false},
+      {4u, 41u, 0.f, 0.f, 0.f, 0.f, 10.f, 0.f, true, false},
     };
   struct GlyphInfoData glyphs02[] =
     {
       {1u, 38u, 0.f, 0.f, 0.f, 0.f, 10.f, 0.f, false, false},
-      {2u, 39u, 0.f, 0.f, 0.f, 0.f, 10.f, 0.f, false, true},
+      {2u, 39u, 0.f, 0.f, 0.f, 0.f, 10.f, 0.f, false, false},
       {3u, 40u, 0.f, 0.f, 0.f, 0.f, 10.f, 0.f, true, false},
-      {4u, 41u, 0.f, 0.f, 0.f, 0.f, 10.f, 0.f, true, true},
+      {4u, 41u, 0.f, 0.f, 0.f, 0.f, 10.f, 0.f, true, false},
     };
 
   CharacterIndex characterIndices[]   = {0u, 1u, 2u, 3u};
index 36125c5f78ad869a31e57162d1e68e7451d97354..94fa9dfbcf07318f20b07fe572b2c388966e35e9 100644 (file)
@@ -480,7 +480,7 @@ int UtcDaliToolkitTextLabelSetSpannedText_BoldSpan(void)
   DALI_TEST_EQUALS(validFonts.Count(), 2, TEST_LOCATION);
   DALI_TEST_EQUALS(validFonts[0].characterRun.characterIndex, 0, TEST_LOCATION);
   DALI_TEST_EQUALS(validFonts[0].characterRun.GetEndCharacterIndex(), 3, TEST_LOCATION);
-  DALI_TEST_EQUALS(validFonts[0].isBoldRequired, true, TEST_LOCATION);
+  DALI_TEST_EQUALS(validFonts[0].isBoldRequired, false, TEST_LOCATION);
   END_TEST;
 }
 
index c5a823adb47be01053ad30ea171b7e7a3cae7b71..8abc3afd7502dc20e87b493e37fd45cdeba3c875 100644 (file)
@@ -681,6 +681,22 @@ void MultilanguageSupport::ValidateFonts(TextAbstraction::FontClient&
     FontId fontId = fontClient.GetFontId(currentFontDescription, currentFontPointSize);
     currentFontId = fontId;
 
+    // Prevent double-bolding from both markup and style
+    bool isFontChangedByBold = false;
+
+    if(currentFontDescription.weight == TextAbstraction::FontWeight::BOLD)
+    {
+      TextAbstraction::FontDescription currentFontDescriptionWithoutBold = TextAbstraction::FontDescription(currentFontDescription);
+      currentFontDescriptionWithoutBold.weight = TextAbstraction::FontWeight::NORMAL;
+
+      FontId fontIdWithoutBold = fontClient.GetFontId(currentFontDescriptionWithoutBold, currentFontPointSize);
+      if(fontId != fontIdWithoutBold)
+      {
+        // If a font is already changed by the bold feature, do not let Freetype further embolden it.
+        isFontChangedByBold = true;
+      }
+    }
+
     // Get the script for the current character.
     Script script = GetScript(index,
                               scriptRunIt,
@@ -825,7 +841,7 @@ void MultilanguageSupport::ValidateFonts(TextAbstraction::FontClient&
     }
 
     // Whether bols style is required.
-    isBoldRequired = (currentFontDescription.weight >= TextAbstraction::FontWeight::BOLD);
+    isBoldRequired = (!isFontChangedByBold && (currentFontDescription.weight >= TextAbstraction::FontWeight::BOLD));
 
     // Whether italic style is required.
     isItalicRequired = (currentFontDescription.slant >= TextAbstraction::FontSlant::ITALIC);