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