diff options
Diffstat (limited to 'libraries/evas/src/lib/engines/common/language/evas_language_utils.c')
-rw-r--r-- | libraries/evas/src/lib/engines/common/language/evas_language_utils.c | 152 |
1 files changed, 0 insertions, 152 deletions
diff --git a/libraries/evas/src/lib/engines/common/language/evas_language_utils.c b/libraries/evas/src/lib/engines/common/language/evas_language_utils.c deleted file mode 100644 index b362f10..0000000 --- a/libraries/evas/src/lib/engines/common/language/evas_language_utils.c +++ /dev/null | |||
@@ -1,152 +0,0 @@ | |||
1 | /** | ||
2 | * @internal | ||
3 | * @addtogroup Evas_Utils | ||
4 | * | ||
5 | * @{ | ||
6 | */ | ||
7 | /** | ||
8 | * @internal | ||
9 | * @defgroup Evas_Script Evas Script (language) utility functions | ||
10 | * | ||
11 | * This set of functions and types helps evas handle scripts correctly. | ||
12 | * @todo Document types, structures and macros. | ||
13 | * | ||
14 | * @{ | ||
15 | */ | ||
16 | #ifdef HAVE_CONFIG_H | ||
17 | # include <config.h> | ||
18 | #endif | ||
19 | |||
20 | #include <stdlib.h> | ||
21 | |||
22 | #include <Eina.h> | ||
23 | |||
24 | #include "evas_language_utils.h" | ||
25 | #include "evas_bidi_utils.h" /* Used for splitting according to bidi */ | ||
26 | #include "../evas_font_ot.h" /* Used for harfbuzz info */ | ||
27 | |||
28 | #ifdef USE_HARFBUZZ | ||
29 | # include <hb.h> | ||
30 | #endif | ||
31 | |||
32 | #include "evas_script_table.h" | ||
33 | |||
34 | static Evas_Script_Type | ||
35 | _evas_common_language_char_script_search(Eina_Unicode unicode) | ||
36 | { | ||
37 | int min = 0; | ||
38 | int max = (sizeof(_evas_script_slow_table) / | ||
39 | sizeof(_evas_script_slow_table[0])) - 1; | ||
40 | int mid; | ||
41 | |||
42 | do | ||
43 | { | ||
44 | mid = (min + max) / 2; | ||
45 | |||
46 | if (unicode < _evas_script_slow_table[mid].start) | ||
47 | max = mid - 1; | ||
48 | else if (unicode >= _evas_script_slow_table[mid].start + | ||
49 | _evas_script_slow_table[mid].len) | ||
50 | min = mid + 1; | ||
51 | else | ||
52 | return _evas_script_slow_table[mid].script; | ||
53 | } | ||
54 | while (min <= max); | ||
55 | |||
56 | return EVAS_SCRIPT_UNKNOWN; | ||
57 | } | ||
58 | |||
59 | Evas_Script_Type | ||
60 | evas_common_language_char_script_get(Eina_Unicode unicode) | ||
61 | { | ||
62 | if ((unicode >= 0) && (unicode < EVAS_SCRIPT_DIRECT_TABLE_LIMIT)) | ||
63 | return _evas_script_fast_table[unicode]; | ||
64 | else | ||
65 | return _evas_common_language_char_script_search(unicode); | ||
66 | } | ||
67 | |||
68 | int | ||
69 | evas_common_language_script_end_of_run_get(const Eina_Unicode *str, | ||
70 | const Evas_BiDi_Paragraph_Props *bidi_props, size_t start, int len) | ||
71 | { | ||
72 | /* FIXME: Use the standard segmentation instead */ | ||
73 | Evas_Script_Type first = EVAS_SCRIPT_UNKNOWN; | ||
74 | int i; | ||
75 | for (i = 0 ; i < len ; i++, str++) | ||
76 | { | ||
77 | Evas_Script_Type tmp; | ||
78 | tmp = evas_common_language_char_script_get(*str); | ||
79 | /* Arabic is the first script in the array that's not | ||
80 | * common/inherited. */ | ||
81 | if ((first == EVAS_SCRIPT_UNKNOWN) && (tmp >= EVAS_SCRIPT_ARABIC)) | ||
82 | { | ||
83 | first = tmp; | ||
84 | continue; | ||
85 | } | ||
86 | if ((first != tmp) && (tmp >= EVAS_SCRIPT_ARABIC)) | ||
87 | { | ||
88 | break; | ||
89 | } | ||
90 | } | ||
91 | #ifdef BIDI_SUPPORT | ||
92 | { | ||
93 | int bidi_end; | ||
94 | bidi_end = evas_bidi_end_of_run_get(bidi_props, start, len); | ||
95 | if (bidi_end > 0) | ||
96 | { | ||
97 | i = (i < bidi_end) ? i : bidi_end; | ||
98 | } | ||
99 | } | ||
100 | #else | ||
101 | (void) bidi_props; | ||
102 | (void) start; | ||
103 | #endif | ||
104 | return (i < len) ? i : 0; | ||
105 | } | ||
106 | |||
107 | Evas_Script_Type | ||
108 | evas_common_language_script_type_get(const Eina_Unicode *str, size_t len) | ||
109 | { | ||
110 | Evas_Script_Type script = EVAS_SCRIPT_COMMON; | ||
111 | const Eina_Unicode *end = str + len; | ||
112 | /* Arabic is the first script in the array that's not a common/inherited */ | ||
113 | for ( ; str < end && ((script = evas_common_language_char_script_get(*str)) < EVAS_SCRIPT_ARABIC) ; str++) | ||
114 | ; | ||
115 | return script; | ||
116 | } | ||
117 | |||
118 | const char * | ||
119 | evas_common_language_from_locale_get(void) | ||
120 | { | ||
121 | static char lang[6]; /* FIXME: Maximum length I know about */ | ||
122 | if (*lang) return lang; | ||
123 | |||
124 | const char *locale; | ||
125 | locale = getenv("LANG"); | ||
126 | if (locale && *locale) | ||
127 | { | ||
128 | char *itr; | ||
129 | strncpy(lang, locale, 5); | ||
130 | lang[5] = '\0'; | ||
131 | itr = lang; | ||
132 | while (*itr) | ||
133 | { | ||
134 | if (*itr == '_') | ||
135 | { | ||
136 | *itr = '\0'; | ||
137 | } | ||
138 | itr++; | ||
139 | } | ||
140 | return lang; | ||
141 | } | ||
142 | |||
143 | return ""; | ||
144 | } | ||
145 | |||
146 | /* | ||
147 | * @} | ||
148 | */ | ||
149 | /* | ||
150 | * @} | ||
151 | */ | ||
152 | |||