From 2125e23ac08f9b0879c98c404e79864f4b3c9358 Mon Sep 17 00:00:00 2001 From: Bowon Ryu Date: Tue, 17 Oct 2023 15:36:03 +0900 Subject: [PATCH] Fix ZWJ issue Added ZWJ sequence to solve the issue of ZWJ not working. this patch processes ZWJ as one sequnce. and this condition has been merged with the previous emoji logic. Added exception handling in editable environment. Removed unnecessary variables related to emoji. Change-Id: Id7825732d96c3e87a8c93b6c2e8d57e057eb7435 Signed-off-by: Bowon Ryu --- .../text/controller/text-controller-impl.cpp | 5 ++-- .../internal/text/multi-language-support-impl.cpp | 31 ++++++++-------------- 2 files changed, 14 insertions(+), 22 deletions(-) diff --git a/dali-toolkit/internal/text/controller/text-controller-impl.cpp b/dali-toolkit/internal/text/controller/text-controller-impl.cpp index a84509f..eb85c83 100644 --- a/dali-toolkit/internal/text/controller/text-controller-impl.cpp +++ b/dali-toolkit/internal/text/controller/text-controller-impl.cpp @@ -1305,11 +1305,12 @@ CharacterIndex Controller::Impl::CalculateNewCursorIndex(CharacterIndex index) c if(index < mEventData->mPrimaryCursorPosition) { - cursorIndex -= numberOfCharacters; + cursorIndex = cursorIndex < numberOfCharacters ? 0u : cursorIndex - numberOfCharacters; } else { - cursorIndex += numberOfCharacters; + Length textLength = mModel->mVisualModel->mCharactersToGlyph.Count(); + cursorIndex = cursorIndex + numberOfCharacters > textLength ? textLength : cursorIndex + numberOfCharacters; } // Will update the cursor hook position. diff --git a/dali-toolkit/internal/text/multi-language-support-impl.cpp b/dali-toolkit/internal/text/multi-language-support-impl.cpp index 5a5c0d8..b322683 100644 --- a/dali-toolkit/internal/text/multi-language-support-impl.cpp +++ b/dali-toolkit/internal/text/multi-language-support-impl.cpp @@ -633,7 +633,6 @@ void MultilanguageSupport::ValidateFonts(const Vector& Vector::ConstIterator scriptRunEndIt = scripts.End(); bool isNewParagraphCharacter = false; - FontId previousEmojiFontId = 0u; FontId currentFontId = 0u; FontId previousFontId = 0u; TextAbstraction::Script previousScript = TextAbstraction::UNKNOWN; @@ -710,15 +709,16 @@ void MultilanguageSupport::ValidateFonts(const Vector& isValidFont = fontClient.IsCharacterSupportedByFont(fontId, character); } - bool isCommonScript = false; - bool isEmojiScript = TextAbstraction::IsOneOfEmojiScripts(script); + bool isEmojiScript = IsEmojiColorScript(script) || IsEmojiTextScript(script); + bool isZWJ = TextAbstraction::IsZeroWidthJoiner(character); - if(isEmojiScript && (previousScript == script)) + if((previousScript == script) && + (isEmojiScript || isZWJ)) { - // Emoji sequence should use the previous emoji font. - if(0u != previousEmojiFontId) + // This sequence should use the previous font. + if(0u != previousFontId) { - fontId = previousEmojiFontId; + fontId = previousFontId; isValidFont = true; } } @@ -732,6 +732,9 @@ void MultilanguageSupport::ValidateFonts(const Vector& isValidFont = true; } + // This is valid after CheckFontSupportsCharacter(); + bool isCommonScript = false; + // 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, @@ -778,19 +781,6 @@ void MultilanguageSupport::ValidateFonts(const Vector& } } - // Store the font id when the first character is an emoji. - if(isEmojiScript) - { - if(0u != fontId && previousScript != script) - { - previousEmojiFontId = fontId; - } - } - else - { - previousEmojiFontId = 0u; - } - #ifdef DEBUG_ENABLED if(gLogFilter->IsEnabledFor(Debug::Verbose)) { @@ -849,6 +839,7 @@ void MultilanguageSupport::ValidateFonts(const Vector& // Whether the current character is a new paragraph character. isNewParagraphCharacter = TextAbstraction::IsNewParagraph(character); previousScript = script; + currentFontId = fontId; previousFontId = currentFontId; } // end traverse characters. -- 2.7.4