../3rdparty/harfbuzz/src/harfbuzz-thai.c

Switch to Source codePreprocessed file
LineSource CodeCoverage
1 -
2 -
3 -
4 -
5 -
6 -
7 -
8struct thcell_t { -
9 unsigned char base; -
10 unsigned char hilo; -
11 unsigned char top; -
12}; -
13typedef int (*th_brk_def) (const unsigned char*, int*, size_t); -
14typedef int (*th_render_cell_tis_def) (struct thcell_t cell, unsigned char res[], size_t res_sz, int is_decomp_am); -
15typedef int (*th_render_cell_win_def) (struct thcell_t cell, unsigned char res[], size_t res_sz, int is_decomp_am); -
16typedef int (*th_render_cell_mac_def) (struct thcell_t cell, unsigned char res[], size_t res_sz, int is_decomp_am); -
17typedef size_t (*th_next_cell_def) (const unsigned char *, size_t, struct thcell_t *, int); -
18 -
19 -
20static th_brk_def th_brk = 0; -
21static th_next_cell_def th_next_cell = 0; -
22static th_render_cell_tis_def th_render_cell_tis = 0; -
23static th_render_cell_win_def th_render_cell_win = 0; -
24static th_render_cell_mac_def th_render_cell_mac = 0; -
25 -
26static int init_libthai() { -
27 static HB_Bool initialized = false; -
28 if (!initialized && (!th_brk || !th_next_cell || !th_render_cell_tis || !th_render_cell_win || !th_render_cell_mac)) {
evaluated: !initialized
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:137
partially evaluated: !th_brk
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
never evaluated: !th_next_cell
never evaluated: !th_render_cell_tis
never evaluated: !th_render_cell_win
never evaluated: !th_render_cell_mac
0-137
29 th_brk = (th_brk_def) HB_Library_Resolve("thai", (int)0, "th_brk"); -
30 th_next_cell = (th_next_cell_def)HB_Library_Resolve("thai", 0, "th_next_cell"); -
31 th_render_cell_tis = (th_render_cell_tis_def) HB_Library_Resolve("thai", (int)0, "th_render_cell_tis"); -
32 th_render_cell_win = (th_render_cell_win_def) HB_Library_Resolve("thai", (int)0, "th_render_cell_win"); -
33 th_render_cell_mac = (th_render_cell_mac_def) HB_Library_Resolve("thai", (int)0, "th_render_cell_mac"); -
34 initialized = true; -
35 }
executed: }
Execution Count:2
2
36 if (th_brk && th_next_cell && th_render_cell_tis && th_render_cell_win && th_render_cell_mac)
partially evaluated: th_brk
TRUEFALSE
yes
Evaluation Count:139
no
Evaluation Count:0
partially evaluated: th_next_cell
TRUEFALSE
yes
Evaluation Count:139
no
Evaluation Count:0
partially evaluated: th_render_cell_tis
TRUEFALSE
yes
Evaluation Count:139
no
Evaluation Count:0
partially evaluated: th_render_cell_win
TRUEFALSE
yes
Evaluation Count:139
no
Evaluation Count:0
partially evaluated: th_render_cell_mac
TRUEFALSE
yes
Evaluation Count:139
no
Evaluation Count:0
0-139
37 return 1;
executed: return 1;
Execution Count:139
139
38 else -
39 return 0;
never executed: return 0;
0
40} -
41 -
42static void to_tis620(const HB_UChar16 *string, hb_uint32 len, const char *cstr) -
43{ -
44 hb_uint32 i; -
45 unsigned char *result = (unsigned char *)cstr; -
46 -
47 for (i = 0; i < len; ++i) {
evaluated: i < len
TRUEFALSE
yes
Evaluation Count:622666
yes
Evaluation Count:139
139-622666
48 if (string[i] <= 0xa0)
evaluated: string[i] <= 0xa0
TRUEFALSE
yes
Evaluation Count:28
yes
Evaluation Count:622638
28-622638
49 result[i] = (unsigned char)string[i];
executed: result[i] = (unsigned char)string[i];
Execution Count:28
28
50 else if (string[i] >= 0xe01 && string[i] <= 0xe5b)
evaluated: string[i] >= 0xe01
TRUEFALSE
yes
Evaluation Count:622636
yes
Evaluation Count:2
evaluated: string[i] <= 0xe5b
TRUEFALSE
yes
Evaluation Count:619560
yes
Evaluation Count:3076
2-622636
51 result[i] = (unsigned char)(string[i] - 0xe00 + 0xa0);
executed: result[i] = (unsigned char)(string[i] - 0xe00 + 0xa0);
Execution Count:619560
619560
52 else -
53 result[i] = (unsigned char)~0;
executed: result[i] = (unsigned char)~0;
Execution Count:3078
3078
54 } -
55 -
56 result[len] = 0; -
57}
executed: }
Execution Count:139
139
58static const HB_OpenTypeFeature thai_features[] = { -
59 { ( ( (HB_UInt)'c' << 24 ) | ( (HB_UInt)'c' << 16 ) | ( (HB_UInt)'m' << 8 ) | (HB_UInt)'p' ), CcmpProperty }, -
60 { ( ( (HB_UInt)'l' << 24 ) | ( (HB_UInt)'i' << 16 ) | ( (HB_UInt)'g' << 8 ) | (HB_UInt)'a' ), CcmpProperty }, -
61 { ( ( (HB_UInt)'c' << 24 ) | ( (HB_UInt)'l' << 16 ) | ( (HB_UInt)'i' << 8 ) | (HB_UInt)'g' ), CcmpProperty }, -
62 {0, 0} -
63}; -
64 -
65 -
66 -
67static int tis620_0[128] = { -
68 0, 0, 0, 0, 0, 0, 0, 0, -
69 0, 0, 0, 0, 0, 0, 0, 0, -
70 0, 0, 0, 0, 0, 0, 0, 0, -
71 0, 0, 0, 0, 0, 0, 0, 0, -
72 0x0020, 0x0e01, 0x0e02, 0x0e03, 0x0e04, 0x0e05, 0x0e06, 0x0e07, -
73 0x0e08, 0x0e09, 0x0e0a, 0x0e0b, 0x0e0c, 0x0e0d, 0x0e0e, 0x0e0f, -
74 0x0e10, 0x0e11, 0x0e12, 0x0e13, 0x0e14, 0x0e15, 0x0e16, 0x0e17, -
75 0x0e18, 0x0e19, 0x0e1a, 0x0e1b, 0x0e1c, 0x0e1d, 0x0e1e, 0x0e1f, -
76 0x0e20, 0x0e21, 0x0e22, 0x0e23, 0x0e24, 0x0e25, 0x0e26, 0x0e27, -
77 0x0e28, 0x0e29, 0x0e2a, 0x0e2b, 0x0e2c, 0x0e2d, 0x0e2e, 0x0e2f, -
78 0x0e30, 0x0e31, 0x0e32, 0x0e33, 0x0e34, 0x0e35, 0x0e36, 0x0e37, -
79 0x0e38, 0x0e39, 0x0e3a, 0, 0, 0, 0, 0x0e3f, -
80 0x0e40, 0x0e41, 0x0e42, 0x0e43, 0x0e44, 0x0e45, 0x0e46, 0x0e47, -
81 0x0e48, 0x0e49, 0x0e4a, 0x0e4b, 0x0e4c, 0x0e4d, 0x0e4e, 0x0e4f, -
82 0x0e50, 0x0e51, 0x0e52, 0x0e53, 0x0e54, 0x0e55, 0x0e56, 0x0e57, -
83 0x0e58, 0x0e59, 0x0e5a, 0x0e5b, 0, 0, 0, 0 -
84}; -
85 -
86static int tis620_1[128] = { -
87 0xf89e, 0, 0, 0xf88c, 0xf88f, 0xf892, 0xf895, 0xf898, -
88 0xf88b, 0xf88e, 0xf891, 0xf894, 0xf897, 0, 0, 0xf899, -
89 0xf89a, 0, 0xf884, 0xf889, 0xf885, 0xf886, 0xf887, 0xf888, -
90 0xf88a, 0xf88d, 0xf890, 0xf893, 0xf896, 0, 0, 0, -
91 0, 0x0e01, 0x0e02, 0x0e03, 0x0e04, 0x0e05, 0x0e06, 0x0e07, -
92 0x0e08, 0x0e09, 0x0e0a, 0x0e0b, 0x0e0c, 0x0e0d, 0x0e0e, 0x0e0f, -
93 0x0e10, 0x0e11, 0x0e12, 0x0e13, 0x0e14, 0x0e15, 0x0e16, 0x0e17, -
94 0x0e18, 0x0e19, 0x0e1a, 0x0e1b, 0x0e1c, 0x0e1d, 0x0e1e, 0x0e1f, -
95 0x0e20, 0x0e21, 0x0e22, 0x0e23, 0x0e24, 0x0e25, 0x0e26, 0x0e27, -
96 0x0e28, 0x0e29, 0x0e2a, 0x0e2b, 0x0e2c, 0x0e2d, 0x0e2e, 0x0e2f, -
97 0x0e30, 0x0e31, 0x0e32, 0x0e33, 0x0e34, 0x0e35, 0x0e36, 0x0e37, -
98 0x0e38, 0x0e39, 0x0e3a, 0, 0, 0, 0, 0x0e3f, -
99 0x0e40, 0x0e41, 0x0e42, 0x0e43, 0x0e44, 0x0e45, 0x0e46, 0x0e47, -
100 0x0e48, 0x0e49, 0x0e4a, 0x0e4b, 0x0e4c, 0x0e4d, 0, 0x0e4f, -
101 0x0e50, 0x0e51, 0x0e52, 0x0e53, 0x0e54, 0x0e55, 0x0e56, 0x0e57, -
102 0x0e58, 0x0e59, 0, 0, 0xf89b, 0xf89c, 0xf89d, 0 -
103}; -
104 -
105static int tis620_2[128] = { -
106 0xf700, 0xf701, 0xf702, 0xf703, 0xf704, 0x2026, 0xf705, 0xf706, -
107 0xf707, 0xf708, 0xf709, 0xf70a, 0xf70b, 0xf70c, 0xf70d, 0xf70e, -
108 0xf70f, 0x2018, 0x2019, 0x201c, 0x201d, 0x2022, 0x2013, 0x2014, -
109 0xf710, 0xf711, 0xf712, 0xf713, 0xf714, 0xf715, 0xf716, 0xf717, -
110 0x00a0, 0x0e01, 0x0e02, 0x0e03, 0x0e04, 0x0e05, 0x0e06, 0x0e07, -
111 0x0e08, 0x0e09, 0x0e0a, 0x0e0b, 0x0e0c, 0x0e0d, 0x0e0e, 0x0e0f, -
112 0x0e10, 0x0e11, 0x0e12, 0x0e13, 0x0e14, 0x0e15, 0x0e16, 0x0e17, -
113 0x0e18, 0x0e19, 0x0e1a, 0x0e1b, 0x0e1c, 0x0e1d, 0x0e1e, 0x0e1f, -
114 0x0e20, 0x0e21, 0x0e22, 0x0e23, 0x0e24, 0x0e25, 0x0e26, 0x0e27, -
115 0x0e28, 0x0e29, 0x0e2a, 0x0e2b, 0x0e2c, 0x0e2d, 0x0e2e, 0x0e2f, -
116 0x0e30, 0x0e31, 0x0e32, 0x0e33, 0x0e34, 0x0e35, 0x0e36, 0x0e37, -
117 0x0e38, 0x0e39, 0x0e3a, 0, 0, 0, 0, 0x0e3f, -
118 0x0e40, 0x0e41, 0x0e42, 0x0e43, 0x0e44, 0x0e45, 0x0e46, 0x0e47, -
119 0x0e48, 0x0e49, 0x0e4a, 0x0e4b, 0x0e4c, 0x0e4d, 0x0e4e, 0x0e4f, -
120 0x0e50, 0x0e51, 0x0e52, 0x0e53, 0x0e54, 0x0e55, 0x0e56, 0x0e57, -
121 0x0e58, 0x0e59, 0x0e5a, 0x0e5b, 0xf718, 0xf719, 0xf71a, 0 -
122}; -
123 -
124enum ThaiFontType { -
125 TIS, -
126 WIN, -
127 MAC -
128}; -
129 -
130static int thai_get_glyph_index (ThaiFontType font_type, unsigned char c) -
131{ -
132 switch (font_type){ -
133 case TIS: return (c & 0x80) ? tis620_0[c & 0x7f] : c;
executed: return (c & 0x80) ? tis620_0[c & 0x7f] : c;
Execution Count:412706
412706
134 case WIN: return (c & 0x80) ? tis620_1[c & 0x7f] : c;
never executed: return (c & 0x80) ? tis620_1[c & 0x7f] : c;
0
135 case MAC: return (c & 0x80) ? tis620_2[c & 0x7f] : c;
never executed: return (c & 0x80) ? tis620_2[c & 0x7f] : c;
0
136 default: return 0;
never executed: return 0;
0
137 } -
138}
never executed: }
0
139 -
140static int thai_contain_glyphs (HB_ShaperItem *shaper_item, const int glyph_map[128]) -
141{ -
142 unsigned char c; -
143 -
144 for (c = 0; c < 0x80; c++) {
partially evaluated: c < 0x80
TRUEFALSE
yes
Evaluation Count:4
no
Evaluation Count:0
0-4
145 if ( glyph_map[c] ) {
partially evaluated: glyph_map[c]
TRUEFALSE
yes
Evaluation Count:4
no
Evaluation Count:0
0-4
146 if ( !shaper_item->font->klass->canRender (shaper_item->font, (HB_UChar16 *) &glyph_map[c], 1) )
partially evaluated: !shaper_item->font->klass->canRender (shaper_item->font, (HB_UChar16 *) &glyph_map[c], 1)
TRUEFALSE
yes
Evaluation Count:4
no
Evaluation Count:0
0-4
147 return 0;
executed: return 0;
Execution Count:4
4
148 }
never executed: }
0
149 }
never executed: }
0
150 return 1;
never executed: return 1;
0
151} -
152 -
153static ThaiFontType getThaiFontType(HB_ShaperItem *shaper_item) -
154{ -
155 if ( thai_contain_glyphs (shaper_item, tis620_2) )
partially evaluated: thai_contain_glyphs (shaper_item, tis620_2)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
156 return MAC;
never executed: return MAC;
0
157 else if ( thai_contain_glyphs (shaper_item, tis620_1) )
partially evaluated: thai_contain_glyphs (shaper_item, tis620_1)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
158 return WIN;
never executed: return WIN;
0
159 else -
160 return TIS;
executed: return TIS;
Execution Count:2
2
161} -
162 -
163 -
164 -
165 -
166static HB_Bool HB_ThaiConvertStringToGlyphIndices (HB_ShaperItem *item) -
167{ -
168 char s[128]; -
169 char *cstr = s; -
170 const HB_UChar16 *string = item->string + item->item.pos; -
171 const hb_uint32 len = item->item.length; -
172 unsigned short *logClusters = item->log_clusters; -
173 hb_uint32 i = 0, slen = 0; -
174 -
175 if (!init_libthai())
partially evaluated: !init_libthai()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:120
0-120
176 return HB_BasicShape (item);
never executed: return HB_BasicShape (item);
0
177 -
178 if (len >= 128)
evaluated: len >= 128
TRUEFALSE
yes
Evaluation Count:106
yes
Evaluation Count:14
14-106
179 cstr = (char *)malloc(len*sizeof(char) + 1);
executed: cstr = (char *)malloc(len*sizeof(char) + 1);
Execution Count:106
106
180 -
181 if (!cstr)
partially evaluated: !cstr
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:120
0-120
182 return HB_BasicShape (item);
never executed: return HB_BasicShape (item);
0
183 -
184 to_tis620(string, len, cstr); -
185 -
186 -
187 static ThaiFontType font_type; -
188 static HB_Font itemFont; -
189 if (itemFont != item->font) {
evaluated: itemFont != item->font
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:118
2-118
190 font_type = getThaiFontType (item); -
191 itemFont = item->font; -
192 }
executed: }
Execution Count:2
2
193 -
194 -
195 HB_UChar16 stackglyphString[512]; HB_UChar16 *glyphString = stackglyphString; if (((item->item.length * 2)) >= 512) glyphString = (HB_UChar16 *)malloc(((item->item.length * 2)) * sizeof(HB_UChar16));;
executed: glyphString = (HB_UChar16 *)malloc(((item->item.length * 2)) * sizeof(HB_UChar16));
Execution Count:102
evaluated: ((item->item.length * 2)) >= 512
TRUEFALSE
yes
Evaluation Count:102
yes
Evaluation Count:18
18-102
196 -
197 while (i < item->item.length) {
evaluated: i < item->item.length
TRUEFALSE
yes
Evaluation Count:412525
yes
Evaluation Count:120
120-412525
198 struct thcell_t tis_cell; -
199 unsigned char rglyphs[4]; -
200 int cell_length; -
201 int lgn = 0; -
202 HB_Bool haveSaraAm = false; -
203 -
204 cell_length = th_next_cell ((const unsigned char *)cstr + i, len - i, &tis_cell, true); -
205 haveSaraAm = (cstr[i + cell_length - 1] == (char)0xd3); -
206 -
207 -
208 logClusters[i] = slen; -
209 for (int j = 1; j < cell_length; j++) {
evaluated: j < cell_length
TRUEFALSE
yes
Evaluation Count:2232
yes
Evaluation Count:412525
2232-412525
210 logClusters[i + j] = logClusters[i]; -
211 }
executed: }
Execution Count:2232
2232
212 -
213 -
214 switch (font_type) { -
215 case TIS: lgn = th_render_cell_tis (tis_cell, rglyphs, sizeof(rglyphs) / sizeof(rglyphs[0]), true); break;
executed: break;
Execution Count:412525
412525
216 case WIN: lgn = th_render_cell_mac (tis_cell, rglyphs, sizeof(rglyphs) / sizeof(rglyphs[0]), true); break;
never executed: break;
0
217 case MAC: lgn = th_render_cell_win (tis_cell, rglyphs, sizeof(rglyphs) / sizeof(rglyphs[0]), true); break;
never executed: break;
0
218 } -
219 -
220 -
221 for (int lgi = 0; lgi < lgn; lgi++) {
evaluated: lgi < lgn
TRUEFALSE
yes
Evaluation Count:822309
yes
Evaluation Count:412525
412525-822309
222 if ( rglyphs[lgi] == 0xdd ) {
evaluated: rglyphs[lgi] == 0xdd
TRUEFALSE
yes
Evaluation Count:407552
yes
Evaluation Count:414757
407552-414757
223 glyphString[slen++] = C_DOTTED_CIRCLE; -
224 } else if (cstr[i] == (signed char)~0) {
executed: }
Execution Count:407552
evaluated: cstr[i] == (signed char)~0
TRUEFALSE
yes
Evaluation Count:2051
yes
Evaluation Count:412706
2051-412706
225 -
226 -
227 glyphString[slen++] = string[i]; -
228 if (string[i] == 0x200D || string[i] == 0x200C) {
evaluated: string[i] == 0x200D
TRUEFALSE
yes
Evaluation Count:2049
yes
Evaluation Count:2
evaluated: string[i] == 0x200C
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1
1-2049
229 -
230 -
231 -
232 if (slen <= item->num_glyphs)
evaluated: slen <= item->num_glyphs
TRUEFALSE
yes
Evaluation Count:1542
yes
Evaluation Count:508
508-1542
233 item->attributes[slen-1].dontPrint = true;
executed: item->attributes[slen-1].dontPrint = true;
Execution Count:1542
1542
234 }
executed: }
Execution Count:2050
2050
235 } else {
executed: }
Execution Count:2051
2051
236 glyphString[slen++] = (HB_UChar16) thai_get_glyph_index (font_type, rglyphs[lgi]); -
237 }
executed: }
Execution Count:412706
412706
238 } -
239 if (haveSaraAm) {
partially evaluated: haveSaraAm
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:412525
0-412525
240 logClusters[i + cell_length - 1] = cell_length == 1 ? slen - 3 : slen - 1;
never evaluated: cell_length == 1
0
241 if (tis_cell.top != 0) {
never evaluated: tis_cell.top != 0
0
242 if (cell_length > 1) {
never evaluated: cell_length > 1
0
243 -
244 -
245 logClusters[i + cell_length - 2] = slen - 2; -
246 }
never executed: }
0
247 }
never executed: }
0
248 -
249 if (logClusters[i + cell_length - 1] > slen)
never evaluated: logClusters[i + cell_length - 1] > slen
0
250 logClusters[i + cell_length - 1] = 0;
never executed: logClusters[i + cell_length - 1] = 0;
0
251 }
never executed: }
0
252 -
253 i += cell_length; -
254 }
executed: }
Execution Count:412525
412525
255 glyphString[slen] = (HB_UChar16) '\0'; -
256 -
257 -
258 HB_Bool spaceOK = (item->num_glyphs >= slen); -
259 -
260 -
261 HB_Bool haveGlyphs = item->font->klass->convertStringToGlyphIndices ( -
262 item->font, -
263 glyphString, slen, -
264 item->glyphs, &item->num_glyphs, -
265 item->shaperFlags); -
266 -
267 if (stackglyphString != glyphString) free(glyphString);;
executed: free(glyphString);
Execution Count:102
evaluated: stackglyphString != glyphString
TRUEFALSE
yes
Evaluation Count:102
yes
Evaluation Count:18
18-102
268 -
269 if (len >= 128)
evaluated: len >= 128
TRUEFALSE
yes
Evaluation Count:106
yes
Evaluation Count:14
14-106
270 free(cstr);
executed: free(cstr);
Execution Count:106
106
271 -
272 return (haveGlyphs && spaceOK);
executed: return (haveGlyphs && spaceOK);
Execution Count:120
120
273} -
274 -
275 -
276 -
277 -
278static void HB_ThaiHeuristicSetGlyphAttributes (HB_ShaperItem *item) -
279{ -
280 -
281 hb_uint32 iCluster = 0; -
282 hb_uint32 length = item->item.length; -
283 while (iCluster < length) {
evaluated: iCluster < length
TRUEFALSE
yes
Evaluation Count:206701
yes
Evaluation Count:69
69-206701
284 int cluster_start = item->log_clusters[iCluster]; -
285 ++iCluster; -
286 while (iCluster < length && item->log_clusters[iCluster] == cluster_start) {
evaluated: iCluster < length
TRUEFALSE
yes
Evaluation Count:207840
yes
Evaluation Count:69
evaluated: item->log_clusters[iCluster] == cluster_start
TRUEFALSE
yes
Evaluation Count:1208
yes
Evaluation Count:206632
69-207840
287 ++iCluster; -
288 }
executed: }
Execution Count:1208
1208
289 int cluster_end = (iCluster < length) ? item->log_clusters[iCluster] : item->num_glyphs;
evaluated: (iCluster < length)
TRUEFALSE
yes
Evaluation Count:206632
yes
Evaluation Count:69
69-206632
290 item->attributes[cluster_start].clusterStart = true; -
291 for (int i = cluster_start + 1; i < cluster_end; i++) {
evaluated: i < cluster_end
TRUEFALSE
yes
Evaluation Count:204984
yes
Evaluation Count:206701
204984-206701
292 item->attributes[i].clusterStart = false; -
293 }
executed: }
Execution Count:204984
204984
294 }
executed: }
Execution Count:206701
206701
295}
executed: }
Execution Count:69
69
296 -
297 -
298 -
299 -
300HB_Bool HB_ThaiShape (HB_ShaperItem *shaper_item) -
301{ -
302 if ( !HB_ThaiConvertStringToGlyphIndices (shaper_item) )
evaluated: !HB_ThaiConvertStringToGlyphIndices (shaper_item)
TRUEFALSE
yes
Evaluation Count:51
yes
Evaluation Count:69
51-69
303 return false;
executed: return false;
Execution Count:51
51
304 -
305 HB_ThaiHeuristicSetGlyphAttributes (shaper_item); -
306 -
307 -
308 const int availableGlyphs = shaper_item->num_glyphs; -
309 if ( HB_SelectScript (shaper_item, thai_features) ) {
partially evaluated: HB_SelectScript (shaper_item, thai_features)
TRUEFALSE
yes
Evaluation Count:69
no
Evaluation Count:0
0-69
310 HB_OpenTypeShape (shaper_item, 0); -
311 return HB_OpenTypePosition (shaper_item, availableGlyphs, true);
executed: return HB_OpenTypePosition (shaper_item, availableGlyphs, true);
Execution Count:69
69
312 } -
313 -
314 -
315 HB_HeuristicPosition (shaper_item); -
316 return true;
never executed: return true;
0
317} -
318 -
319 -
320 -
321 -
322static void HB_ThaiAssignAttributes(const HB_UChar16 *string, hb_uint32 len, HB_CharAttributes *attributes) -
323{ -
324 char s[128]; -
325 char *cstr = s; -
326 int *break_positions = 0; -
327 int brp[128]; -
328 int brp_size = 0; -
329 hb_uint32 numbreaks, i, j, cell_length; -
330 struct thcell_t tis_cell; -
331 -
332 if (!init_libthai())
partially evaluated: !init_libthai()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:19
0-19
333 return ;
never executed: return ;
0
334 -
335 if (len >= 128)
evaluated: len >= 128
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:14
5-14
336 cstr = (char *)malloc(len*sizeof(char) + 1);
executed: cstr = (char *)malloc(len*sizeof(char) + 1);
Execution Count:5
5
337 -
338 to_tis620(string, len, cstr); -
339 -
340 for (i = 0; i < len; ++i) {
evaluated: i < len
TRUEFALSE
yes
Evaluation Count:207909
yes
Evaluation Count:19
19-207909
341 attributes[i].wordBreak = 0; -
342 attributes[i].wordStart = 0; -
343 attributes[i].wordEnd = 0; -
344 attributes[i].lineBreak = 0; -
345 }
executed: }
Execution Count:207909
207909
346 -
347 if (len > 128) {
evaluated: len > 128
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:14
5-14
348 break_positions = (int*) malloc (sizeof(int) * len); -
349 memset (break_positions, 0, sizeof(int) * len); -
350 brp_size = len; -
351 }
executed: }
Execution Count:5
5
352 else { -
353 break_positions = brp; -
354 brp_size = 128; -
355 }
executed: }
Execution Count:14
14
356 -
357 if (break_positions) {
partially evaluated: break_positions
TRUEFALSE
yes
Evaluation Count:19
no
Evaluation Count:0
0-19
358 attributes[0].wordBreak = (!0); -
359 attributes[0].wordStart = (!0); -
360 attributes[0].wordEnd = 0; -
361 numbreaks = th_brk((const unsigned char *)cstr, break_positions, brp_size); -
362 for (i = 0; i < numbreaks; ++i) {
evaluated: i < numbreaks
TRUEFALSE
yes
Evaluation Count:1314
yes
Evaluation Count:19
19-1314
363 attributes[break_positions[i]].wordBreak = (!0); -
364 attributes[break_positions[i]].wordStart = (!0); -
365 attributes[break_positions[i]].wordEnd = (!0); -
366 attributes[break_positions[i]].lineBreak = (!0); -
367 }
executed: }
Execution Count:1314
1314
368 if (numbreaks > 0)
evaluated: numbreaks > 0
TRUEFALSE
yes
Evaluation Count:14
yes
Evaluation Count:5
5-14
369 attributes[break_positions[numbreaks - 1]].wordStart = 0;
executed: attributes[break_positions[numbreaks - 1]].wordStart = 0;
Execution Count:14
14
370 -
371 if (break_positions != brp)
evaluated: break_positions != brp
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:14
5-14
372 free(break_positions);
executed: free(break_positions);
Execution Count:5
5
373 }
executed: }
Execution Count:19
19
374 -
375 -
376 i = 0; -
377 while (i < len) {
evaluated: i < len
TRUEFALSE
yes
Evaluation Count:206701
yes
Evaluation Count:19
19-206701
378 cell_length = th_next_cell((const unsigned char *)cstr + i, len - i, &tis_cell, true); -
379 -
380 attributes[i].graphemeBoundary = true; -
381 for (j = 1; j < cell_length; j++)
evaluated: j < cell_length
TRUEFALSE
yes
Evaluation Count:1208
yes
Evaluation Count:206701
1208-206701
382 attributes[i + j].graphemeBoundary = false;
executed: attributes[i + j].graphemeBoundary = false;
Execution Count:1208
1208
383 -
384 -
385 if (cstr[i + cell_length - 1] == (char)0xd3)
partially evaluated: cstr[i + cell_length - 1] == (char)0xd3
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:206701
0-206701
386 attributes[i + cell_length - 1].graphemeBoundary = true;
never executed: attributes[i + cell_length - 1].graphemeBoundary = true;
0
387 -
388 i += cell_length; -
389 }
executed: }
Execution Count:206701
206701
390 -
391 if (len >= 128)
evaluated: len >= 128
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:14
5-14
392 free(cstr);
executed: free(cstr);
Execution Count:5
5
393}
executed: }
Execution Count:19
19
394 -
395void HB_ThaiAttributes(HB_Script script, const HB_UChar16 *text, hb_uint32 from, hb_uint32 len, HB_CharAttributes *attributes) -
396{ -
397 ((script == HB_Script_Thai) ? static_cast<void> (0) : __assert_fail ("script == HB_Script_Thai", "../3rdparty/harfbuzz/src/harfbuzz-thai.c", 454, __PRETTY_FUNCTION__)); -
398 const HB_UChar16 *uc = text + from; -
399 attributes += from; -
400 ((script) = (script)); -
401 HB_ThaiAssignAttributes(uc, len, attributes); -
402}
executed: }
Execution Count:19
19
403 -
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial