From: Bowon Ryu Date: Mon, 28 Mar 2022 10:14:24 +0000 (+0000) Subject: Merge "Handle Emoji clustering for cursor handling" into devel/master X-Git-Tag: dali_2.1.16~6 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=commitdiff_plain;h=645bdbb832026172a6868286e000769645062c2c;hp=-c Merge "Handle Emoji clustering for cursor handling" into devel/master --- 645bdbb832026172a6868286e000769645062c2c diff --combined dali-toolkit/internal/file.list index 65d46fb,3fae741..355667e --- a/dali-toolkit/internal/file.list +++ b/dali-toolkit/internal/file.list @@@ -140,6 -140,7 +140,7 @@@ SET( toolkit_src_file ${toolkit_src_dir}/text/bidirectional-support.cpp ${toolkit_src_dir}/text/bounded-paragraph-helper-functions.cpp ${toolkit_src_dir}/text/character-set-conversion.cpp + ${toolkit_src_dir}/text/characters-helper-functions.cpp ${toolkit_src_dir}/text/color-segmentation.cpp ${toolkit_src_dir}/text/cursor-helper-functions.cpp ${toolkit_src_dir}/text/glyph-metrics-helper.cpp @@@ -154,7 -155,6 +155,7 @@@ ${toolkit_src_dir}/text/markup-processor-span.cpp ${toolkit_src_dir}/text/markup-processor-strikethrough.cpp ${toolkit_src_dir}/text/markup-processor-underline.cpp + ${toolkit_src_dir}/text/markup-processor-character-spacing.cpp ${toolkit_src_dir}/text/markup-processor-helper-functions.cpp ${toolkit_src_dir}/text/markup-processor-attribute-helper-functions.cpp ${toolkit_src_dir}/text/multi-language-support.cpp @@@ -204,8 -204,7 +205,8 @@@ ${toolkit_src_dir}/text/rendering/text-typesetter.cpp ${toolkit_src_dir}/text/rendering/view-model.cpp ${toolkit_src_dir}/text/rendering/styles/underline-helper-functions.cpp - ${toolkit_src_dir}/text/rendering/styles/strikethrough-helper-functions + ${toolkit_src_dir}/text/rendering/styles/strikethrough-helper-functions.cpp + ${toolkit_src_dir}/text/rendering/styles/character-spacing-helper-functions.cpp ${toolkit_src_dir}/transition/fade-transition-impl.cpp ${toolkit_src_dir}/transition/slide-transition-impl.cpp ${toolkit_src_dir}/transition/scale-transition-impl.cpp diff --combined dali-toolkit/internal/text/cursor-helper-functions.cpp index 3b3bf44,d895418..5dfebde --- a/dali-toolkit/internal/text/cursor-helper-functions.cpp +++ b/dali-toolkit/internal/text/cursor-helper-functions.cpp @@@ -22,8 -22,9 +22,10 @@@ #include // INTERNAL INCLUDES + #include + #include #include +#include namespace { @@@ -215,10 -216,7 +217,10 @@@ CharacterIndex GetClosestCursorIndex(Vi { return logicalIndex; } - const float characterSpacing = visualModel->GetCharacterSpacing(); + + // Get the character-spacing runs. + const Vector& characterSpacingGlyphRuns = visualModel->GetCharacterSpacingGlyphRuns(); + const float modelCharacterSpacing = visualModel->GetCharacterSpacing(); // Whether there is a hit on a line. bool matchedLine = false; @@@ -293,8 -291,7 +295,8 @@@ // Get the metrics for the group of glyphs. GlyphMetrics glyphMetrics; - calculatedAdvance = GetCalculatedAdvance(*(logicalModel->mText.Begin() + (*(glyphToCharacterMapBuffer + firstLogicalGlyphIndex))), characterSpacing, (*(visualModel->mGlyphs.Begin() + firstLogicalGlyphIndex)).advance); + const float characterSpacing = GetGlyphCharacterSpacing(firstLogicalGlyphIndex, characterSpacingGlyphRuns, modelCharacterSpacing); + calculatedAdvance = GetCalculatedAdvance(*(logicalModel->mText.Begin() + (*(glyphToCharacterMapBuffer + firstLogicalGlyphIndex))), characterSpacing, (*(visualModel->mGlyphs.Begin() + firstLogicalGlyphIndex)).advance); GetGlyphsMetrics(firstLogicalGlyphIndex, numberOfGlyphs, glyphMetrics, @@@ -463,6 -460,19 +465,19 @@@ logicalIndex = (bidiLineFetched ? logicalModel->GetLogicalCursorIndex(visualIndex) : visualIndex); + // Handle Emoji clustering for cursor handling: + // Fixing this case: + // - When there is Emoji contains multi unicodes and it is layoutted at the end of line (LineWrap case , is not new line case) + // - Try to click at the center or at the end of Emoji then the cursor appears inside Emoji + // - Example:"FamilyManWomanGirlBoy 👨‍👩‍👧‍👦" + const Script script = logicalModel->GetScript(logicalIndex); + if(IsOneOfEmojiScripts(script)) + { + //TODO: Use this clustering for Emoji cases only. This needs more testing to generalize to all scripts. + CharacterRun emojiClusteredCharacters = RetrieveClusteredCharactersOfCharacterIndex(visualModel, logicalModel, logicalIndex); + logicalIndex = emojiClusteredCharacters.characterIndex; + } + DALI_LOG_INFO(gLogFilter, Debug::Verbose, "closest visualIndex %d logicalIndex %d\n", visualIndex, logicalIndex); DALI_ASSERT_DEBUG((logicalIndex <= logicalModel->mText.Count() && logicalIndex >= 0) && "GetClosestCursorIndex - Out of bounds index"); @@@ -611,9 -621,7 +626,9 @@@ void GetCursorPosition(GetCursorPositio const Length* const charactersPerGlyphBuffer = parameters.visualModel->mCharactersPerGlyph.Begin(); const CharacterIndex* const glyphsToCharactersBuffer = parameters.visualModel->mGlyphsToCharacters.Begin(); const Vector2* const glyphPositionsBuffer = parameters.visualModel->mGlyphPositions.Begin(); - const float characterSpacing = parameters.visualModel->GetCharacterSpacing(); + const float modelCharacterSpacing = parameters.visualModel->GetCharacterSpacing(); + + const Vector& characterSpacingGlyphRuns = parameters.visualModel->GetCharacterSpacingGlyphRuns(); // Get the metrics for the group of glyphs. GetGlyphMetricsFromCharacterIndex(index, parameters.visualModel, parameters.logicalModel, metrics, glyphMetrics, glyphIndex, numberOfGlyphs); @@@ -730,7 -738,6 +745,7 @@@ const bool addGlyphAdvance = ((!isFirstPositionOfLine && !isCurrentRightToLeft) || (isFirstPositionOfLine && !isRightToLeftParagraph)); + const float characterSpacing = GetGlyphCharacterSpacing(secondaryGlyphIndex, characterSpacingGlyphRuns, modelCharacterSpacing); cursorInfo.secondaryPosition.x = -glyphMetrics.xBearing + secondaryPosition.x + (addGlyphAdvance ? (glyphMetrics.advance + characterSpacing) : 0.f); cursorInfo.secondaryPosition.y = cursorInfo.lineOffset + cursorInfo.lineHeight - cursorInfo.secondaryCursorHeight; diff --combined dali-toolkit/internal/text/text-controller-text-updater.cpp index e31a3f1,f49e953..35408da --- a/dali-toolkit/internal/text/text-controller-text-updater.cpp +++ b/dali-toolkit/internal/text/text-controller-text-updater.cpp @@@ -24,6 -24,8 +24,8 @@@ // INTERNAL INCLUDES #include + #include + #include #include #include #include @@@ -92,8 -94,7 +94,8 @@@ void Controller::TextUpdater::SetText(C logicalModel->mUnderlinedCharacterRuns, logicalModel->mBackgroundColorRuns, logicalModel->mStrikethroughCharacterRuns, - logicalModel->mBoundedParagraphRuns); + logicalModel->mBoundedParagraphRuns, + logicalModel->mCharacterSpacingCharacterRuns); Length textSize = 0u; const uint8_t* utf8 = NULL; @@@ -482,6 -483,7 +484,7 @@@ bool Controller::TextUpdater::RemoveTex ModelPtr& model = impl.mModel; LogicalModelPtr& logicalModel = model->mLogicalModel; + VisualModelPtr& visualModel = model->mVisualModel; DALI_LOG_INFO(gLogFilter, Debug::General, "Controller::RemoveText %p mText.Count() %d cursor %d cursorOffset %d numberOfCharacters %d\n", &controller, logicalModel->mText.Count(), eventData->mPrimaryCursorPosition, cursorOffset, numberOfCharacters); @@@ -499,6 -501,25 +502,25 @@@ cursorIndex = eventData->mPrimaryCursorPosition + cursorOffset; } + //Handle Emoji clustering for cursor handling + // Deletion case: this is handling the deletion cases when the cursor is before or after Emoji + // - Before: when use delete key and cursor is before Emoji (cursorOffset = -1) + // - After: when use backspace key and cursor is after Emoji (cursorOffset = 0) + + const Script script = logicalModel->GetScript(cursorIndex); + if((numberOfCharacters == 1u) && + (IsOneOfEmojiScripts(script))) + { + //TODO: Use this clustering for Emoji cases only. This needs more testing to generalize to all scripts. + CharacterRun emojiClusteredCharacters = RetrieveClusteredCharactersOfCharacterIndex(visualModel, logicalModel, cursorIndex); + Length actualNumberOfCharacters = emojiClusteredCharacters.numberOfCharacters; + + //Set cursorIndex at the first characterIndex of clustred Emoji + cursorIndex = emojiClusteredCharacters.characterIndex; + + numberOfCharacters = actualNumberOfCharacters; + } + if((cursorIndex + numberOfCharacters) > currentText.Count()) { numberOfCharacters = currentText.Count() - cursorIndex;