Merge branch 'devel/master' into sandbox/dkdk/tizen
[platform/core/uifw/dali-adaptor.git] / dali / devel-api / text-abstraction / script.h
1 #ifndef DALI_TOOLKIT_TEXT_ABSTRACTION_SCRIPT_H
2 #define DALI_TOOLKIT_TEXT_ABSTRACTION_SCRIPT_H
3
4 /*
5  * Copyright (c) 2020 Samsung Electronics Co., Ltd.
6  *
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
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
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.
18  *
19  */
20
21 // INTERNAL INCLUDES
22 #include <dali/devel-api/text-abstraction/text-abstraction-definitions.h>
23 #include <dali/public-api/dali-adaptor-common.h>
24
25 namespace Dali
26 {
27 namespace TextAbstraction
28 {
29 /**
30  * @brief Script is the writing system used by a language.
31  * Typically one script can be used to write different languages although one language could be written in different scrips.
32  */
33 enum Script
34 {
35   COMMON, ///< Valid for all scripts. i.e white space or '\n'.
36
37   ASCII_DIGITS, ///< ASCII digits.
38   ASCII_PS,     ///< ASCII punctuation and symbols.
39
40   C1_CONTROLS, ///< Controls of the C1 Controls and Latin-1 Supplement unicode block.
41   C1_PS,       ///< Punctuation and symbols of the C1 Controls and Latin-1 Supplement unicode block.
42   C1_MATH,     ///< Math symbols of the C1 Controls and Latin-1 Supplement unicode block.
43
44   SML_P,       ///< Punctuation symbols of the Spacing Modifier Letters unicode block.
45   PHONETIC_U,  ///< Uralic phonetic symbols of the Phonetic Extensions unicode block.
46   PHONETIC_SS, ///< Subscripts and superscripts of the Phonetic Extensions unicode block.
47
48   NUMERIC_SS, ///< Numeric subscripts and superscripts.
49
50   LETTER_LIKE,   ///< Symbols of the Letterlike unicode block.
51   NUMBER_FORMS,  ///< Number Forms unicode block.
52   FRACTIONS_NF,  ///< Numeric fraction symbols of the Number Forms unicode block.
53   NON_LATIN_LED, ///< Non latin symbols within the Latin Extended D unicode block.
54   HWFW_S,        ///< Non latin symbols within the Halfwidth and fullwidth unicode block.
55
56   CYRILLIC, ///< The Cyrillic script. Used by Russian, Bulgarian, Ukrainian, Macedonian, ...
57   GREEK,    ///< The Greek script. Used by Greek.
58   LATIN,    ///< The latin script. Used by many western languages and others around the world.
59
60   ARABIC, ///< The arabic script. Used by Arab and Urdu among others.
61   HEBREW, ///< The Hebrew script. Used by the Hebrew, Yiddish, Ladino, and Judeo-Arabic.
62
63   ARMENIAN, ///< The Armenian script. Used by Armenian.
64   GEORGIAN, ///< The Georgian script. Used by Georgian.
65
66   CJK,      ///< The CJK script. Used by Chinese, Japanese, Korean and Vietnamese(old writing system).
67   HANGUL,   ///< The Hangul jamo script. Used by Korean.
68   HIRAGANA, ///< The Hiragana script. Used by the Japanese.
69   KATAKANA, ///< The Katakana script. Used by the Japanese.
70   BOPOMOFO, ///< The Bopomofo script. Also called Zhuyin fuhao or Zhuyin. A phonetic notation used for the transcription of spoken Chinese.
71
72   BENGALI,    ///< The Bengali script. Used by Bangla, Assamese, Bishnupriya Manipuri, Daphla, Garo, Hallam, Khasi, Mizo, Munda, Naga, Rian, and Santali.
73   BURMESE,    ///< The Burmese script. Used by the Burmese (Myanmar) language.
74   DEVANAGARI, ///< The devanagari script. Used by Hindi, Marathi, Sindhi, Nepali and Sanskrit.
75   GUJARATI,   ///< The Gujarati script. Used by Gujarati.
76   GURMUKHI,   ///< The Gurmukhi script. Used by Punjabi.
77   KANNADA,    ///< The Kannada script. Used by Kannada and Tulu.
78   MALAYALAM,  ///< The Malayalam script. Used by Malayalam.
79   ORIYA,      ///< The Oriya script. Used by Oriya (Odia), Khondi, and Santali.
80   SINHALA,    ///< The Sinhala script. Used by Sinhala and Pali.
81   TAMIL,      ///< The Tamil script. Used by Tamil, Badaga, and Saurashtra.
82   TELUGU,     ///< The Telugu script. Used by Telugu, Gondi, and Lambadi.
83
84   LAO,       ///< The Lao script. Used by the Lao language.
85   THAI,      ///< The Thai script. Used by the Thai language
86   KHMER,     ///< The Khmer script. Used by the Khmer language.
87   JAVANESE,  ///< The Javanese script. Used by the Javanese language.
88   SUNDANESE, ///< The Sundanese script. Used by the Sundanese language.
89
90   GEEZ,     ///< The Ge'ez script. Used by the Amharic, Tigrinya and other languages in Ethiopia and Eritrea.
91   OL_CHIKI, ///< The Ol Chiki script. Used by the Santali.
92   BAYBAYIN, ///< The Baybayin script. Used by the Tagalog, Bikol languages, Ilocano, Pangasinan, Visayan and other languages in Philippines.
93   MEITEI,   ///< The Meitei script used for the Meitei language in Manipur, India.
94
95   EMOJI, ///< The Emoji which map to standardized Unicode characters.
96
97   SYMBOLS1, ///< Some symbols.
98   SYMBOLS2, ///< Some symbols.
99   SYMBOLS3, ///< Some symbols.
100   SYMBOLS4, ///< Some symbols.
101   SYMBOLS5, ///< Some symbols.
102
103   UNKNOWN ///< The script is unknown.
104 };
105
106 const char* const ScriptName[] =
107   {
108     "COMMON", ///< Valid for all scripts. i.e white space or '\n'.
109
110     "ASCII_DIGITS", ///< ASCII digits.
111     "ASCII_PS",     ///< ASCII punctuation and symbols.
112
113     "C1_CONTROLS", ///< Controls of the C1 Controls and Latin-1 Supplement unicode block.
114     "C1_PS",       ///< Punctuation and symbols of the C1 Controls and Latin-1 Supplement unicode block.
115     "C1_MATH",     ///< Math symbols of the C1 Controls and Latin-1 Supplement unicode block.
116
117     "SML_P",       ///< Punctuation symbols of the Spacing Modifier Letters unicode block.
118     "PHONETIC_U",  ///< Uralic phonetic symbols of the Phonetic Extensions unicode block.
119     "PHONETIC_SS", ///< Subscripts and superscripts of the Phonetic Extensions unicode block.
120
121     "NUMERIC_SS", ///< Numeric subscripts and superscripts.
122
123     "LETTER_LIKE",   ///< Symbols of the Letterlike unicode block.
124     "NUMBER_FORMS",  ///< Number Forms unicode block.
125     "FRACTIONS_NF",  ///< Numeric fraction symbols of the Number Forms unicode block.
126     "NON_LATIN_LED", ///< Non latin symbols within the Latin Extended D unicode block.
127     "HWFW_S",        ///< Non latin symbols within the Halfwidth and fullwidth unicode block.
128
129     "CYRILLIC", ///< The Cyrillic script. Used by Russian, Bulgarian, Ukrainian, Macedonian, ...
130     "GREEK",    ///< The Greek script. Used by Greek.
131     "LATIN",    ///< The latin script. Used by many western languages and others around the world.
132
133     "ARABIC", ///< The arabic script. Used by Arab and Urdu among others.
134     "HEBREW", ///< The Hebrew script. Used by the Hebrew, Yiddish, Ladino, and Judeo-Arabic.
135
136     "ARMENIAN", ///< The Armenian script. Used by Armenian.
137     "GEORGIAN", ///< The Georgian script. Used by Georgian.
138
139     "CJK",      ///< The CJK script. Used by Chinese, Japanese, Korean and Vietnamese(old writing system).
140     "HANGUL",   ///< The Hangul jamo script. Used by Korean.
141     "HIRAGANA", ///< The Hiragana script. Used by the Japanese.
142     "KATAKANA", ///< The Katakana script. Used by the Japanese.
143     "BOPOMOFO", ///< The Bopomofo script. Also called Zhuyin fuhao or Zhuyin. A phonetic notation used for the transcription of spoken Chinese.
144
145     "BENGALI",    ///< The Bengali script. Used by Bangla, Assamese, Bishnupriya Manipuri, Daphla, Garo, Hallam, Khasi, Mizo, Munda, Naga, Rian, and Santali.
146     "BURMESE",    ///< The Burmese script. Used by the Burmese (Myanmar) language.
147     "DEVANAGARI", ///< The devanagari script. Used by Hindi, Marathi, Sindhi, Nepali and Sanskrit.
148     "GUJARATI",   ///< The Gujarati script. Used by Gujarati.
149     "GURMUKHI",   ///< The Gurmukhi script. Used by Punjabi.
150     "KANNADA",    ///< The Kannada script. Used by Kannada and Tulu.
151     "MALAYALAM",  ///< The Malayalam script. Used by Malayalam.
152     "ORIYA",      ///< The Oriya script. Used by Oriya (Odia), Khondi, and Santali.
153     "SINHALA",    ///< The Sinhala script. Used by Sinhala and Pali.
154     "TAMIL",      ///< The Tamil script. Used by Tamil, Badaga, and Saurashtra.
155     "TELUGU",     ///< The Telugu script. Used by Telugu, Gondi, and Lambadi.
156
157     "LAO",       ///< The Lao script. Used by the Lao language.
158     "THAI",      ///< The Thai script. Used by the Thai language
159     "KHMER",     ///< The Khmer script. Used by the Khmer language.
160     "JAVANESE",  ///< The Javanese script. Used by the Javanese language.
161     "SUNDANESE", ///< The Sundanese script. Used by the Sundanese language.
162
163     "GEEZ",     ///< The Ge'ez script also known as Ethiopic. Used by the Amharic, Tigrinya and other languages in Ethiopia and Eritrea.
164     "OL_CHIKI", ///< The Ol Chiki script. Used by the Santali.
165     "BAYBAYIN", ///< The Baybayin script. Used by the Tagalog, Bikol languages, Ilocano, Pangasinan, Visayan and other languages in Philippines.
166     "MEITEI",   ///< The Meitei script used for the Meitei language in Manipur, India.
167
168     "EMOJI", ///< The Emoji which map to standardized Unicode characters.
169
170     "SYMBOLS1", ///< Some symbols.
171     "SYMBOLS2", ///< Some symbols.
172     "SYMBOLS3", ///< Some symbols.
173     "SYMBOLS4", ///< Some symbols.
174     "SYMBOLS5", ///< Some symbols.
175
176     "UNKNOWN" ///< The script is unknown.
177 };
178
179 /**
180  * @brief Whether the script is a right to left script.
181  *
182  * @param[in] script The script.
183  *
184  * @return @e true if the script is right to left.
185  */
186 DALI_ADAPTOR_API bool IsRightToLeftScript(Script script);
187
188 /**
189  * @brief Retrieves a character's script.
190  *
191  * @param[in] character The character.
192  *
193  * @return The chraracter's script.
194  */
195 DALI_ADAPTOR_API Script GetCharacterScript(Character character);
196
197 /**
198  * @brief Whether the character is a white space.
199  *
200  * @param[in] character The character.
201  *
202  * @return @e true if the character is a white space.
203  */
204 DALI_ADAPTOR_API bool IsWhiteSpace(Character character);
205
206 /**
207  * @brief Whether the character is a new paragraph character.
208  *
209  * @param[in] character The character.
210  *
211  * @return @e true if the character is a new paragraph character.
212  */
213 DALI_ADAPTOR_API bool IsNewParagraph(Character character);
214
215 /**
216  * @brief Whether the character is a zero width non joiner.
217  *
218  * @param[in] character The character.
219  *
220  * @return @e true if the character is a zero width non joiner.
221  */
222 DALI_ADAPTOR_API bool IsZeroWidthNonJoiner(Character character);
223
224 /**
225  * @brief Whether the character is a zero width joiner.
226  *
227  * @param[in] character The character.
228  *
229  * @return @e true if the character is a zero width joiner.
230  */
231 DALI_ADAPTOR_API bool IsZeroWidthJoiner(Character character);
232
233 /**
234  * @brief Whether the character is a zero width space.
235  *
236  * @param[in] character The character.
237  *
238  * @return @e true if the character is a zero width space.
239  */
240 DALI_ADAPTOR_API bool IsZeroWidthSpace(Character character);
241
242 /**
243  * @brief Whether the character is a left to right mark.
244  *
245  * @param[in] character The character.
246  *
247  * @return @e true if the character is a left to right mark.
248  */
249 DALI_ADAPTOR_API bool IsLeftToRightMark(Character character);
250
251 /**
252  * @brief Whether the character is a right to left mark.
253  *
254  * @param[in] character The character.
255  *
256  * @return @e true if the character is a right to left mark.
257  */
258 DALI_ADAPTOR_API bool IsRightToLeftMark(Character character);
259
260 /**
261  * @brief Whether the character is a thin space.
262  *
263  * @param[in] character The character.
264  *
265  * @return @e true if the character is a thin space.
266  */
267 DALI_ADAPTOR_API bool IsThinSpace(Character character);
268
269 /**
270  * @brief Whether the character is common within all scripts.
271  *
272  * @param[in] character The character.
273  *
274  * @return @e true if the character is common within all scripts.
275  */
276 DALI_ADAPTOR_API bool IsCommonScript(Character character);
277
278 /**
279  * @brief Whether the script contains ligatures that must be 'broken' for selection or cursor position.
280  *
281  * i.e The latin script has the 'ff' or 'fi' ligatures that need to be broken to position the cursor
282  * between the two characters. Equally the arabic script has the 'ﻻ' ligature that needs to be broken.
283  *
284  * @param[in] script The script.
285  *
286  * @return @e true if the script has ligatures that must be 'broken'.
287  */
288 DALI_ADAPTOR_API bool HasLigatureMustBreak(Script script);
289 } // namespace TextAbstraction
290
291 } // namespace Dali
292
293 #endif // DALI_TOOLKIT_TEXT_ABSTRACTION_SCRIPT_H