[Tizen] Fix space font validation condition 81/288881/1
authorjoogab.yun <joogab.yun@samsung.com>
Thu, 23 Feb 2023 09:38:06 +0000 (18:38 +0900)
committerBowon Ryu <bowon.ryu@samsung.com>
Fri, 24 Feb 2023 04:50:42 +0000 (13:50 +0900)
when character is 0x20, there are various cases of font validation.
but if it is a default font or cached font, or
if a glyph exists in the current font when it is contiguous with the prev char,
it is natural to load current font.
this is same behaviour as before.. and the process of finding fonts can slightly reduced.

Change-Id: I017db2ec38e86642a83a44739a0d2c7af072e14a

dali-toolkit/internal/text/multi-language-support-impl.cpp

index f24d427..2ba2793 100644 (file)
@@ -468,8 +468,10 @@ void MultilanguageSupport::ValidateFonts(const Vector<Character>&
   Vector<ScriptRun>::ConstIterator scriptRunEndIt          = scripts.End();
   bool                             isNewParagraphCharacter = false;
 
-  FontId                  previousEmojiFontId = 0u;
-  TextAbstraction::Script previousScript      = TextAbstraction::UNKNOWN;
+  FontId previousEmojiFontId = 0u;
+  FontId currentFontId       = 0u;
+  FontId previousFontId      = 0u;
+  TextAbstraction::Script previousScript = TextAbstraction::UNKNOWN;
 
   CharacterIndex lastCharacter = startIndex + numberOfCharacters - 1u;
   for(Length index = startIndex; index <= lastCharacter; ++index)
@@ -493,6 +495,7 @@ void MultilanguageSupport::ValidateFonts(const Vector<Character>&
 
     // Get the font for the current character.
     FontId fontId = fontClient.GetFontId(currentFontDescription, currentFontPointSize);
+    currentFontId = fontId;
 
     // Get the script for the current character.
     Script script = GetScript(index,
@@ -554,6 +557,15 @@ void MultilanguageSupport::ValidateFonts(const Vector<Character>&
       }
     }
 
+    if(TextAbstraction::IsSpace(character) &&
+       TextAbstraction::HasLigatureMustBreak(script) &&
+       isValidCachedDefaultFont &&
+       (isDefaultFont || (currentFontId == previousFontId)))
+    {
+      fontId      = cachedDefaultFontId;
+      isValidFont = true;
+    }
+
     // If the given font is not valid, it means either:
     // - there is no cached font for the current script yet or,
     // - the user has set a different font than the default one for the current script or,
@@ -776,6 +788,7 @@ void MultilanguageSupport::ValidateFonts(const Vector<Character>&
     // Whether the current character is a new paragraph character.
     isNewParagraphCharacter = TextAbstraction::IsNewParagraph(character);
     previousScript          = script;
+    previousFontId          = currentFontId;
   } // end traverse characters.
 
   if(0u != currentFontRun.characterRun.numberOfCharacters)