1 #ifndef DALI_TOOLKIT_TEXT_EMOJI_HELPER_H
2 #define DALI_TOOLKIT_TEXT_EMOJI_HELPER_H
5 * Copyright (c) 2021 Samsung Electronics Co., Ltd.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
22 #include <dali-toolkit/internal/text/text-definitions.h>
25 #include <dali/devel-api/text-abstraction/emoji-character-properties.h>
26 #include <dali/devel-api/text-abstraction/emoji-helper.h>
27 #include <dali/devel-api/text-abstraction/script.h>
36 * @brief Whether the sequence is a variation sequence consisting of an emoji character followed by a text presentation selector.
38 * @param[in] currentRunScript The script of current run.
39 * @param[in] character The next character.
41 * @return @e true if the sequence is text presentation sequence.
43 bool IsTextPresentationSequence(const TextAbstraction::Script& currentRunScript, const TextAbstraction::Character& character);
46 * @brief Whether the sequence is a variation sequence consisting of an emoji character followed by a emoji presentation selector.
48 * @param[in] currentRunScript The script of current run.
49 * @param[in] character The next character.
51 * @return @e true if the sequence is emoji presentation sequence.
53 bool IsEmojiPresentationSequence(const TextAbstraction::Script& currentRunScript,
54 const TextAbstraction::Character& character);
57 * @brief Whether the sequence is an emoji sequence.
59 * @param[in] currentRunScript The script of current run.
60 * @param[in] character The next character.
61 * @param[in] characterScript The script of the next character.
63 * @return @e true if the sequence is an emoji sequence.
65 bool IsEmojiSequence(const TextAbstraction::Script& currentRunScript,
66 const TextAbstraction::Character& character,
67 const TextAbstraction::Script& characterScript);
70 * @brief Whether the sequence is a keycap sequence and set script according to the case.
72 * @param[in] textBuffer The text.
73 * @param[in] currentCharacterIndex The index of current character.
74 * @param[in] lastCharacterIndex The index of last character.
75 * @param[out] currentCharacterScript The current character script to update it in-case it's the Keycap sequence.
77 * @return @e true if @p currentRunScript is ASCII_DIGITS and @p character is COMBINING_ENCLOSING_KEYCAP
79 bool IsNewKeycapSequence(const Character* const textBuffer,
80 const Length& currentCharacterIndex,
81 const Length& lastCharacterIndex,
82 TextAbstraction::Script& currentCharacterScript);
85 * @brief Whether the sequence is a variation selector sequence and set script according to the case.
87 * @param[in] textBuffer The text.
88 * @param[in] currentRunScript The script of current run.
89 * @param[in] currentCharacterIndex The index of current character.
90 * @param[in] lastCharacterIndex The index of last character.
91 * @param[out] currentCharacterScript The current character script to update it in-case it's the VariationSelector sequence.
93 * @return @e true if @p currentRunScript is ASCII_DIGITS and @p character is COMBINING_ENCLOSING_KEYCAP
95 bool IsNewVariationSelectorSequence(const Character* const textBuffer,
96 const TextAbstraction::Script& currentRunScript,
97 const Length& currentCharacterIndex,
98 const Length& lastCharacterIndex,
99 TextAbstraction::Script& currentCharacterScript);
102 * @brief Whether the case is a new sequence and set script according to the case.
104 * @param[in] textBuffer The text.
105 * @param[in] currentRunScript The script of current run.
106 * @param[in] currentCharacterIndex The index of current character.
107 * @param[in] lastCharacterIndex The index of last character.
108 * @param[out] currentCharacterScript The current character script to update according to sequence.
110 * @return @e true the case is a new sequence
112 bool IsNewSequence(const Character* const textBuffer,
113 const TextAbstraction::Script& currentRunScript,
114 const Length& currentCharacterIndex,
115 const Length& lastCharacterIndex,
116 TextAbstraction::Script& currentCharacterScript);
119 * @brief Whether the character is ASCII digits | # Number Sign | * Asterisk.
121 * @param[in] character The character.
123 * @return @e true if the character is ASCII digits | # Number Sign | * Asterisk.
125 bool IsStartForKeycapSequence(const TextAbstraction::Character& character);
128 * @brief Check sequence case and update script of character if needed.
130 * @param[in] currentRunScript The script of current run.
131 * @param[in] character The next character.
132 * @param[out] script The current character script to update according to sequence.
134 * @return @e true if the script is changed
136 bool IsScriptChangedToFollowSequence(const TextAbstraction::Script& currentRunScript,
137 const TextAbstraction::Character& character,
138 TextAbstraction::Script& script);
141 * @brief Check sequence case and update script of character if needed.
143 * @param[in] currentRunScript The script of current run.
144 * @param[in] character The next character.
145 * @param[out] script The current character script to update according to sequence.
147 * @return @e true if the script is changed
149 bool HandleEmojiSequence(const Character* const textBuffer,
150 const Length& currentCharacterIndex,
151 const Length& lastCharacterIndex,
152 const TextAbstraction::Script& currentRunScript,
153 TextAbstraction::Script& currentCharacterScript);
156 * @brief Determine the Variation Selector according to script.
158 * @param[in] script The script.
160 * @return CHAR_VARIATION_SELECTOR_15 in-case EMOJI_TEXT or CHAR_VARIATION_SELECTOR_16 in-case EMOJI_COLOR or 0 otherwise
162 Character GetVariationSelectorByScript(const TextAbstraction::Script& script);
166 } // namespace Toolkit
170 #endif // DALI_TOOLKIT_TEXT_EMOJI_HELPER_H