e0e4c2676bebebfa73af80cc07d611b3aa1d5411
[platform/core/uifw/dali-adaptor.git] / text / dali / devel-api / text-abstraction / script.cpp
1 /*
2  * Copyright (c) 2015 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 // FILE HEADER
19 #include <dali/devel-api/text-abstraction/script.h>
20
21 namespace Dali
22 {
23
24 namespace TextAbstraction
25 {
26
27 namespace
28 {
29 const unsigned int WHITE_SPACE_THRESHOLD  = 0x21; ///< All characters below 0x21 are considered white spaces.
30 const unsigned int CHAR_LF   = 0x000A; ///< NL Line feed, new line.
31 const unsigned int CHAR_VT   = 0x000B; ///< Vertical tab.
32 const unsigned int CHAR_FF   = 0x000C; ///< NP Form feed, new page.
33 const unsigned int CHAR_CR   = 0x000D; ///< Carriage return, new line.
34 const unsigned int CHAR_NEL  = 0x0085; ///< Next line.
35 const unsigned int CHAR_LS   = 0x2028; ///< Line separator.
36 const unsigned int CHAR_PS   = 0x2029; ///< Paragraph separator
37
38 const unsigned int CHAR_ZWS  = 0x200B; ///< Zero width space.
39 const unsigned int CHAR_ZWNJ = 0x200C; ///< Zero width non joiner.
40 const unsigned int CHAR_ZWJ  = 0x200D; ///< Zero width joiner.
41 const unsigned int CHAR_LTRM = 0x200E; ///< Left to Right Mark.
42 const unsigned int CHAR_RTLM = 0x200F; ///< Right to Left Mark.
43 const unsigned int CHAR_TS   = 0x2009; ///< Thin Space.
44 } // namespace
45
46 bool IsRightToLeftScript( Script script )
47 {
48   return ( ( ARABIC == script ) ||
49            ( HEBREW == script ) );
50 }
51
52 Script GetCharacterScript( Character character )
53 {
54   // Latin script:   It contains punctuation characters and symbols which are not part of the latin script. https://en.wikipedia.org/wiki/Latin_script_in_Unicode
55   // 0x0000 - 0x007f C0 Controls and Basic Latin
56   //
57   //                 ASCII digits (not part of LATIN script):
58   //                 0x0030 - 0x0039
59   //
60   //                 ASCII punctuation and symbols (not part of LATIN script):
61   //                 0x0020 - 0x002F
62   //                 0x003A - 0x0040
63   //                 0x005B - 0x0060
64   //                 0x007B - 0x007E
65   //
66   //                 Controls (not part of LATIN script):
67   //                 0x007F
68   //
69   // 0x0080 - 0x00ff C1 Controls and Latin-1 Supplement
70   //
71   //                 Controls (not part of LATIN script):
72   //                 0x0080 - 0x009F
73   //
74   //                 Punctuations and symbols (not part of LATIN script):
75   //                 0x00A0 - 0x00BF
76   //
77   //                 Mathematical operators (not part of LATIN script):
78   //                 0x00D7
79   //                 0x00F7
80   //
81   // 0x0100 - 0x017f Latin Extended-A
82   // 0x0180 - 0x024f Latin Extended-B
83   // 0x0250 - 0x02af IPA Extensions
84   // 0x02b0 - 0x02ff Spacing Modifier Letters
85   //
86   //                 Punctuation (not part of LATIN script):
87   //                 0x02B9 - 0x02BF
88   //
89   // 0x1d00 - 0x1d7f Phonetic Extensions
90   //
91   //                 Uralic Phonetic (not part of LATIN script):
92   //                 0x1D26 - 0x1D2B
93   //
94   //                 Subscripts and superscripts
95   //                 0x1D5D - 0x1D61
96   //                 0x1D66 - 0x1D6A
97   //                 0x1D78
98   //
99   // 0x1d80 - 0x1dbf Phonetic Extensions Supplement
100   //
101   //                 0x1DBF (subscript or superscript. Not part of LATIN script )
102   //
103   // 0x1e00 - 0x1eff Latin Extended Additional
104   // 0x2070 - 0x209f Superscripts and Subscripts
105   //
106   //                 0x2070          (not part of LATIN script)
107   //                 0x2074 - 0x207E (not part of LATIN script)
108   //
109   // 0x2100 - 0x214f Letterlike symbols (not part of LATIN script)
110   //
111   //                 0x212A - 0x212B (are part of LATIN script)
112   //                 0x2132          (are part of LATIN script)
113   //                 0x214E          (are part of LATIN script)
114   //
115   // 0x2150 - 0x2189 Number Forms
116   //
117   //                 0x2150 - 0x215F Fractions (not part of LATIN script)
118   //                 0x2189          Fractions (not part of LATIN script)
119   //
120   // 0x2c60 - 0x2c7f Latin Extended-C
121   // 0xa720 - 0xa7ff Latin Extended-D
122   //
123   //                 0xA720 - 0xA721 Uralic Phonetic (not part of LATIN script)
124   //                 0xA788          (not part of LATIN script)
125   //                 0xA789 - 0xA78A Budu (not part of LATIN script)
126   //
127   // 0xab30 - 0xab6f Latin Extended-E
128   //
129   // 0xfb00 - 0xfb06 Latin Alphabetic Presentation Forms
130   // 0xff00 - 0xffef Halfwidth and Fullwidth Forms
131   //
132   //                 0xFF00 - 0xFF20 HWFW Symbols (not part of LATIN script)
133   //                 0xFF3B - 0xFF40 HWFW Symbols (not part of LATIN script)
134   //                 0xFF5B - 0xFFEF HWFW Symbols (not part of LATIN script)
135
136   // Brahmic scripts:
137   // 0x0900 - 0x097f Devanagari
138   // 0x0980 - 0x09ff Bengali
139   // 0x0a00 - 0x0a7f Gurmukhi
140   // 0x0a80 - 0x0aff Gujarati
141   // 0x0b00 - 0x0b7f Oriya
142   // 0x0b80 - 0x0bff Tamil
143   // 0x0c00 - 0x0c7f Telugu
144   // 0x0c80 - 0x0cff Kannada
145   // 0x0d00 - 0x0d7f Malayalam
146
147   // Sinhala script.
148   // 0x0d80 - 0x0dff Sinhala
149
150   // Arabic script.
151   // 0x0600 - 0x06ff Arabic
152   // 0x0750 - 0x077f Arabic Supplement
153   // 0x08A0 - 0x08ff Arabic Extended-A
154   // 0xfb50 - 0xfdff Arabic Presentation Forms-A
155   // 0xfe70 - 0xfeff Arabic Presentation Forms-B
156   // 0x1ee00 - 0x1eeff Arabic Mathematical Alphabetic Symbols
157
158   // CJK (Chinese, Japanese and Korean) and Vietnamese script.
159   // 0x2e80 - 0x2eff CJK Radicals Supplement
160   // 0x2f00 - 0x2fdf Kangxi Radicals
161   // 0x3000 - 0x303f CJK Symbols and Punctuation
162   // 0x3200 - 0x32ff Enclosed CJK Letters and Months
163   // 0x3400 - 0x4dbf CJK Unified Ideographs Extension A
164   // 0x4e00 - 0x62ff CJK Unified Ideographs
165   // 0x6300 - 0x77ff CJK Unified Ideographs
166   // 0x7800 - 0x8cff CJK Unified Ideographs
167   // 0x8d00 - 0x9fff CJK Unified Ideographs
168   // 0x20000 - 0x215ff CJK Unified Ideographs Extension B
169   // 0x21600 - 0x230ff CJK Unified Ideographs Extension B
170   // 0x23100 - 0x245ff CJK Unified Ideographs Extension B
171   // 0x24600 - 0x260ff CJK Unified Ideographs Extension B
172   // 0x26100 - 0x275ff CJK Unified Ideographs Extension B
173   // 0x27600 - 0x290ff CJK Unified Ideographs Extension B
174   // 0x29100 - 0x2a6df CJK Unified Ideographs Extension B
175   // 0x2a700 - 0x2b73f CJK Unified Ideographs Extension C
176   // 0x2b740 - 0x2b81f CJK Unified Ideographs Extension D
177
178   // Japanese scripts.
179   // 0x3040 - 0x309f Hiragana
180   // 0x30a0 - 0x30ff Katakana
181
182   // Hangul script
183   // 0x1100 - 0x11ff Hangul jamo
184   // 0x3130 - 0x318f Hangul Compatibility Jamo
185   // 0xa960 - 0xa97f Hangul Jamo Extended-A
186   // 0xac00 - 0xd7af Hangul Syllables
187   // 0xd7b0 - 0xd7ff Hangul Jamo Extended-B
188
189   // Bopomofo script
190   // 0x3100 - 0x312f Bopomofo
191   // 0x31a0 - 0x31bf Bopomofo Extended
192
193   // Khmer script
194   // 0x1780 - 0x17ff Khmer
195   // 0x19e0 - 0x19ff Khmer Symbols
196
197   // Lao script
198   // 0x0e80 - 0x0eff Lao
199
200   // Thai script
201   // 0x0e00 - 0x0e7f Thai
202
203   // Burmese script
204   // 0x1000 - 0x109f Myanmar
205
206   // Hebrew script
207   // 0x0591 - 0x05f4 Hebrew
208   // 0xfb1d - 0xfb4f Hebrew subset of Alphabetic Presentation Forms
209
210   // Cyrillic script
211   // 0x0400 - 0x04ff Cyrillic
212   // 0x0500 - 0x052f Cyrillic suplement
213   // 0x2de0 - 0x2dff Cyrillic Extended-A
214   // 0xa640 - 0xa69f Cyrillic Extended-B
215
216   // Georgian script
217   // 0x10a0 - 0x10ff Georgian
218   // 0x2d00 - 0x2d2f Georgian suplement
219
220   // Greek script
221   // 0x0370 - 0x03ff Greek & Coptic
222   // 0x1f00 - 0x1fff Greek Extended
223
224   // Armenian script
225   // 0x0530 - 0x058f Armenian
226   // 0xfb13 - 0xfb17 Armenian subset of Alphabetic prefentation forms
227
228   // Javanese script
229   // 0xa980 - 0xa9fd Javanese
230
231   // Sundanese script
232   // 0x1b80 - 0x1bbf Sundanese
233   // 0x1cc0 - 0x1ccf Sundanese supplement
234
235   // The Emoji which map to standardized Unicode characters
236   // 1. Emoticons ( 1F601 - 1F64F )
237   // 2. Dingbats ( 2702 - 27B0 )
238   // 3. Transport and map symbols ( 1F680 - 1F6C0 )
239   // 4. Enclosed characters ( 24C2 - 1F251 )
240   // 5. Uncategorized :-S
241   // 6. Additional Emoticons ( 1F600 - 1F636 )
242   // 6b. Additional transport and map symbols ( 1F681 - 1F6C5 )
243   // 6c. Other additional symbols ( 1F30D - 1F567 )
244
245   // Symbols. Work around for these symbols.
246   // 0x25cb
247   // 0x25cf
248   // 0x25a1
249   // 0x25a0
250   // 0x2664
251   // 0x2661
252   // 0x2662
253   // 0x2667
254   // 0x2606
255   // 0x25aa
256   // 0x262a
257
258   if( IsCommonScript( character ) )
259   {
260     return COMMON;
261   }
262
263   if( character <= 0x0cff )
264   {
265     if( character <= 0x09ff )
266     {
267       if( character <= 0x077f )
268       {
269         if( ( 0x0030 <= character ) && ( character <= 0x0039 ) )
270         {
271           return ASCII_DIGITS;
272         }
273         if( character <= 0x007E )
274         {
275           if( ( 0x0020 <= character ) && ( character <= 0x002F ) )
276           {
277             return ASCII_PS;
278           }
279           if( ( 0x003A <= character ) && ( character <= 0x0040 ) )
280           {
281             return ASCII_PS;
282           }
283           if( ( 0x005B <= character ) && ( character <= 0x0060 ) )
284           {
285             return ASCII_PS;
286           }
287           if( ( 0x007B <= character ) && ( character <= 0x007E ) )
288           {
289             return ASCII_PS;
290           }
291         }
292         if( ( 0x007F <= character ) && ( character <= 0x009F ) )
293         {
294           // 0x007F is actually part of C0 Controls and Basic Latin. However, is the last and only control character of its block
295           // and the following characters of the next block are consecutive.
296           return C1_CONTROLS;
297         }
298         if( ( 0x00A0 <= character ) && ( character <= 0x00BF ) )
299         {
300           if( character == 0x00A9 )
301           {
302             return EMOJI; // 5. Uncategorized: copyright sign
303           }
304           if( character == 0x00AE )
305           {
306             return EMOJI; // 5. Uncategorized: registered sign
307           }
308
309           return C1_PS;
310         }
311         if( character == 0x00D7 )
312         {
313           return C1_MATH;
314         }
315         if( character == 0x00F7 )
316         {
317           return  C1_MATH;
318         }
319         if( character <= 0x02ff )
320         {
321           if( ( 0x02B9 <= character ) && ( character <= 0x02BF ) )
322           {
323             return SML_P;
324           }
325
326           return LATIN;
327         }
328         if( ( 0x0370 <= character ) && ( character <= 0x03ff ) )
329         {
330           return GREEK;
331         }
332         if( ( 0x0400 <= character ) && ( character <= 0x04ff ) )
333         {
334           return CYRILLIC;
335         }
336         if( ( 0x0500 <= character ) && ( character <= 0x052f ) )
337         {
338           return CYRILLIC;
339         }
340         if( ( 0x0530 <= character ) && ( character <= 0x058f ) )
341         {
342           return ARMENIAN;
343         }
344         if( ( 0x0591 <= character ) && ( character <= 0x05f4 ) )
345         {
346           return HEBREW;
347         }
348         if( ( 0x0600 <= character ) && ( character <= 0x06ff ) )
349         {
350           return ARABIC;
351         }
352         if( ( 0x0750 <= character ) && ( character <= 0x077f ) )
353         {
354           return ARABIC;
355         }
356       }
357       else // > 0x077f
358       {
359         if( ( 0x08A0 <= character ) && ( character <= 0x08ff ) )
360         {
361           return ARABIC;
362         }
363         if( ( 0x0900 <= character ) && ( character <= 0x097f ) )
364         {
365           return DEVANAGARI;
366         }
367         if( ( 0x0980 <= character ) && ( character <= 0x09ff ) )
368         {
369           return BENGALI;
370         }
371       }
372     }
373     else // > 0x09ff
374     {
375       if( character <= 0x0b7f )
376       {
377         if( ( 0x0a00 <= character ) && ( character <= 0x0a7f ) )
378         {
379           return GURMUKHI;
380         }
381         if( ( 0x0a80 <= character ) && ( character <= 0x0aff ) )
382         {
383           return GUJARATI;
384         }
385         if( ( 0x0b00 <= character ) && ( character <= 0x0b7f ) )
386         {
387           return ORIYA;
388         }
389       }
390       else // > 0x0b7f
391       {
392         if( ( 0x0b80 <= character ) && ( character <= 0x0bff ) )
393         {
394           return TAMIL;
395         }
396         if( ( 0x0c00 <= character ) && ( character <= 0x0c7f ) )
397         {
398           return TELUGU;
399         }
400         if( ( 0x0c80 <= character ) && ( character <= 0x0cff ) )
401         {
402           return KANNADA;
403         }
404       }
405     }
406   }
407   else // > 0x0cff
408   {
409     if( character <= 0x2c7f )
410     {
411       if( character <= 0x1eff )
412       {
413         if( ( 0x0d00 <= character ) && ( character <= 0x0d7f ) )
414         {
415           return MALAYALAM;
416         }
417         if( ( 0x0d80 <= character ) && ( character <= 0x0dff ) )
418         {
419           return SINHALA;
420         }
421         if( ( 0x0e00 <= character ) && ( character <= 0x0e7f ) )
422         {
423           return THAI;
424         }
425         if( ( 0x0e80 <= character ) && ( character <= 0x0eff ) )
426         {
427           return LAO;
428         }
429         if( ( 0x1000 <= character ) && ( character <= 0x109f ) )
430         {
431           return BURMESE;
432         }
433         if( ( 0x10a0 <= character ) && ( character <= 0x10ff ) )
434         {
435           return GEORGIAN;
436         }
437         if( ( 0x1100 <= character ) && ( character <= 0x11ff ) )
438         {
439           return HANGUL;
440         }
441         if( ( 0x1780 <= character ) && ( character <= 0x17ff ) )
442         {
443           return KHMER;
444         }
445         if( ( 0x19e0 <= character ) && ( character <= 0x19ff ) )
446         {
447           return KHMER;
448         }
449         if( ( 0x1b80 <= character ) && ( character <= 0x1bbf ) )
450         {
451           return SUNDANESE;
452         }
453         if( ( 0x1cc0 <= character ) && ( character <= 0x1ccf ) )
454         {
455           return SUNDANESE;
456         }
457         if( ( 0x1d00 <= character ) && ( character <= 0x1eff ) )
458         {
459           if( ( 0x1D26 <= character ) && ( character <= 0x1D2B ) )
460           {
461             return PHONETIC_U;
462           }
463           if( ( 0x1D5D <= character ) && ( character <= 0x1D61 ) )
464           {
465             return PHONETIC_SS;
466           }
467           if( ( 0x1D66 <= character ) && ( character <= 0x1D6A ) )
468           {
469             return PHONETIC_SS;
470           }
471           if( character == 0x1D78 )
472           {
473             return PHONETIC_SS;
474           }
475           if( character == 0x1DBF)
476           {
477             return PHONETIC_SS;
478           }
479
480           return LATIN;
481         }
482       }
483       else // > 0x1eff
484       {
485         if( ( 0x1f00 <= character ) && ( character <= 0x1fff ) )
486         {
487           return GREEK;
488         }
489         if( character == 0x203c )
490         {
491           return EMOJI; // 5. Uncategorized: double exclamation mark
492         }
493         if( character == 0x2049 )
494         {
495           return EMOJI; // 5. Uncategorized: exclamation question mark
496         }
497         if( ( 0x2070 <= character ) && ( character <= 0x209f ) )
498         {
499           if( character == 0x2070 )
500           {
501             return NUMERIC_SS;
502           }
503           if( ( 0x2074 <= character ) && ( character <= 0x207E ) )
504           {
505             return NUMERIC_SS;
506           }
507
508           return LATIN;
509         }
510         if( character == 0x20e3 )
511         {
512           return EMOJI; // 5. Uncategorized: combining enclosing keycap
513         }
514         if( character == 0x2122 )
515         {
516           return EMOJI; // 5. Uncategorized: trade mark sign
517         }
518         if( character == 0x2139 )
519         {
520           return EMOJI; // 5. Uncategorized: information source
521         }
522         if( ( 0x2100 <= character ) && ( character <= 0x2189 ) )
523         {
524           if( ( 0x2100 <= character ) && ( character <= 0x214f ) )
525           {
526             if( ( 0x212A <= character ) && ( character <= 0x212B ) )
527             {
528               return LATIN;
529             }
530             if( character == 0x2132 )
531             {
532               return LATIN;
533             }
534             if( character == 0x214E )
535             {
536               return LATIN;
537             }
538
539             return LETTER_LIKE;
540           }
541           if( ( 0x2150 <= character ) && ( character <= 0x215F ) )
542           {
543             return FRACTIONS_NF;
544           }
545           if( character == 0x2189 )
546           {
547             return FRACTIONS_NF;
548           }
549
550           return LATIN;
551         }
552
553         // Symbols
554         if( ( 0x25cb == character ) ||
555             ( 0x25cf == character ) ||
556             ( 0x25a1 == character ) )
557         {
558           return SYMBOLS1;
559         }
560
561         if( 0x25a0 == character )
562         {
563           return SYMBOLS2;
564         }
565
566         if( ( 0x2664 == character ) ||
567             ( 0x2661 == character ) ||
568             ( 0x2662 == character ) ||
569             ( 0x2667 == character ) )
570         {
571           return SYMBOLS3;
572         }
573
574         if( ( 0x2606 == character ) ||
575             ( 0x25aa == character ) )
576         {
577           return SYMBOLS4;
578         }
579
580         if( 0x262a == character )
581         {
582           return SYMBOLS5;
583         }
584
585         // U+2194 5. Uncategorized: left right arrow
586         // U+2B55 5. Uncategorized: heavy large circle
587         if( ( 0x2194 <= character ) && ( character <= 0x2B55 ) )
588         {
589           return EMOJI;
590         }
591         if( ( 0x2c60 <= character ) && ( character <= 0x2c7f ) )
592         {
593           return LATIN;
594         }
595       }
596     }
597     else // > 0x2c7f
598     {
599       if( character <= 0xfdff )
600       {
601         if( ( 0x2d00 <= character ) && ( character <= 0x2d2f ) )
602         {
603           return GEORGIAN;
604         }
605         if( ( 0x2de0 <= character ) && ( character <= 0x2dff ) )
606         {
607           return CYRILLIC;
608         }
609         if( ( 0x2e80 <= character ) && ( character <= 0x2eff ) )
610         {
611           return CJK;
612         }
613         if( ( 0x2f00 <= character ) && ( character <= 0x2fdf ) )
614         {
615           return CJK;
616         }
617         if( ( 0x3000 <= character ) && ( character <= 0x303f ) )
618         {
619           return CJK;
620         }
621         if( ( 0x3040 <= character ) && ( character <= 0x309f ) )
622         {
623           return HIRAGANA;
624         }
625         if( ( 0x30a0 <= character ) && ( character <= 0x30ff ) )
626         {
627           return KATAKANA;
628         }
629         if( ( 0x3100 <= character ) && ( character <= 0x312f ) )
630         {
631           return BOPOMOFO;
632         }
633         if( ( 0x3130 <= character ) && ( character <= 0x318f ) )
634         {
635           return HANGUL;
636         }
637         if( ( 0x31a0 <= character ) && ( character <= 0x31bf ) )
638         {
639           return BOPOMOFO;
640         }
641         if( ( 0x3200 <= character ) && ( character <= 0x32ff ) )
642         {
643           return CJK;
644         }
645         if( ( 0x3400 <= character ) && ( character <= 0x4dbf ) )
646         {
647           return CJK;
648         }
649         if( ( 0x4e00 <= character ) && ( character <= 0x62ff ) )
650         {
651           return CJK;
652         }
653         if( ( 0x6300 <= character ) && ( character <= 0x77ff ) )
654         {
655           return CJK;
656         }
657         if( ( 0x7800 <= character ) && ( character <= 0x8cff ) )
658         {
659           return CJK;
660         }
661         if( ( 0x8d00 <= character ) && ( character <= 0x9fff ) )
662         {
663           return CJK;
664         }
665         if( ( 0xa640 <= character ) && ( character <= 0xa69f ) )
666         {
667           return CYRILLIC;
668         }
669         if( ( 0xa720 <= character ) && ( character <= 0xa7ff ) )
670         {
671           if( character == 0xA720 )
672           {
673             return PHONETIC_U;
674           }
675           if( character == 0xA721 )
676           {
677             return PHONETIC_U;
678           }
679           if( character == 0xA788 )
680           {
681             return NON_LATIN_LED;
682           }
683           if( character == 0xA789 )
684           {
685             return NON_LATIN_LED;
686           }
687           if( character == 0xA78A )
688           {
689             return NON_LATIN_LED;
690           }
691
692           return LATIN;
693         }
694         if( ( 0xa960 <= character ) && ( character <= 0xa97f ) )
695         {
696           return HANGUL;
697         }
698         if( ( 0xa980 <= character ) && ( character <= 0xa9fd ) )
699         {
700           return JAVANESE;
701         }
702         if( ( 0xab30 <= character ) && ( character <= 0xab6f ) )
703         {
704           return LATIN;
705         }
706         if( ( 0xac00 <= character ) && ( character <= 0xd7af ) )
707         {
708           return HANGUL;
709         }
710         if( ( 0xd7b0 <= character ) && ( character <= 0xd7ff ) )
711         {
712           return HANGUL;
713         }
714         if( ( 0xfb00 <= character ) && ( character <= 0xfb06 ) )
715         {
716           return LATIN;
717         }
718         if( ( 0xfb13 <= character ) && ( character <= 0xfb17 ) )
719         {
720           return ARMENIAN;
721         }
722         if( ( 0xfb1d <= character ) && ( character <= 0xfb4f ) )
723         {
724           return HEBREW;
725         }
726         if( ( 0xfb50 <= character ) && ( character <= 0xfdff ) )
727         {
728           return ARABIC;
729         }
730       }
731       else // > 0xfdff
732       {
733         if( ( 0xfe70 <= character ) && ( character <= 0xfeff ) )
734         {
735           return ARABIC;
736         }
737         if( ( 0xff00 <= character ) && ( character <= 0xffef ) )
738         {
739           if( ( 0xFF00 <= character ) && ( character <= 0xFF20 ) )
740           {
741             return HWFW_S;
742           }
743           if( ( 0xFF3B <= character ) && ( character <= 0xFF40 ) )
744           {
745             return HWFW_S;
746           }
747           if( ( 0xFF5B <= character ) && ( character <= 0xFFEF ) )
748           {
749             return HWFW_S;
750           }
751
752           return LATIN;
753         }
754         if( ( 0x1ee00 <= character ) && ( character <= 0x1eeff ) )
755         {
756           return ARABIC;
757         }
758         // U+1f170 4. Enclosed characters: negative squared latin capital letter A
759         // U+1f6c5 6b. Additional transport and map symbols
760         if( ( 0x1f170 <= character ) && ( character <= 0x1f6c5 ) )
761         {
762           return EMOJI;
763         }
764         if( ( 0x20000 <= character ) && ( character <= 0x215ff ) )
765         {
766           return CJK;
767         }
768         if( ( 0x21600 <= character ) && ( character <= 0x230ff ) )
769         {
770           return CJK;
771         }
772         if( ( 0x23100 <= character ) && ( character <= 0x245ff ) )
773         {
774           return CJK;
775         }
776         if( ( 0x24600 <= character ) && ( character <= 0x260ff ) )
777         {
778           return CJK;
779         }
780         if( ( 0x26100 <= character ) && ( character <= 0x275ff ) )
781         {
782           return CJK;
783         }
784         if( ( 0x27600 <= character ) && ( character <= 0x290ff ) )
785         {
786           return CJK;
787         }
788         if( ( 0x29100 <= character ) && ( character <= 0x2a6df ) )
789         {
790           return CJK;
791         }
792         if( ( 0x2a700 <= character ) && ( character <= 0x2b73f ) )
793         {
794           return CJK;
795         }
796         if( ( 0x2b740 <= character ) && ( character <= 0x2b81f ) )
797         {
798           return CJK;
799         }
800       }
801     }
802   }
803
804   return UNKNOWN;
805 }
806
807 bool IsWhiteSpace( Character character )
808 {
809   return character < WHITE_SPACE_THRESHOLD;
810 }
811
812 bool IsNewParagraph( Character character )
813 {
814   return ( ( CHAR_LF == character )  ||
815            ( CHAR_VT == character )  ||
816            ( CHAR_FF == character )  ||
817            ( CHAR_CR == character )  ||
818            ( CHAR_NEL == character ) ||
819            ( CHAR_LS == character )  ||
820            ( CHAR_PS == character ) );
821 }
822
823 bool IsZeroWidthNonJoiner( Character character )
824 {
825   return CHAR_ZWNJ == character;
826 }
827
828 bool IsZeroWidthJoiner( Character character )
829 {
830   return CHAR_ZWJ == character;
831 }
832
833 bool IsZeroWidthSpace( Character character )
834 {
835   return CHAR_ZWS == character;
836 }
837
838 bool IsLeftToRightMark( Character character )
839 {
840   return CHAR_LTRM == character;
841 }
842
843 bool IsRightToLeftMark( Character character )
844 {
845   return CHAR_RTLM == character;
846 }
847
848 bool IsThinSpace( Character character )
849 {
850   return CHAR_TS == character;
851 }
852
853 bool IsCommonScript( Character character )
854 {
855   return ( IsWhiteSpace( character )         ||
856            IsZeroWidthNonJoiner( character ) ||
857            IsZeroWidthJoiner( character )    ||
858            IsZeroWidthSpace( character )     ||
859            IsLeftToRightMark( character )    ||
860            IsRightToLeftMark( character )    ||
861            IsThinSpace( character )          ||
862            IsNewParagraph( character ) );
863 }
864
865 bool HasLigatureMustBreak( Script script )
866 {
867   return ( ( LATIN == script ) ||
868            ( ARABIC == script ) );
869 }
870
871 } // namespace TextAbstraction
872
873 } // namespace Dali