blob: 1963b5e693581346094f83cfe37aa921e67de48e [file] [log] [blame]
Behdad Esfahboda346e922011-06-28 12:49:18 -04001/*
2 * Copyright © 2011 Google, Inc.
3 * Copyright © 2008 Nokia Corporation and/or its subsidiary(-ies)
4 *
5 * This is part of HarfBuzz, a text shaping library.
6 *
7 * Permission is hereby granted, without written agreement and without
8 * license or royalty fees, to use, copy, modify, and distribute this
9 * software and its documentation for any purpose, provided that the
10 * above copyright notice and the following two paragraphs appear in
11 * all copies of this software.
12 *
13 * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
14 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
15 * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
16 * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
17 * DAMAGE.
18 *
19 * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
20 * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
21 * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
22 * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
23 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
24 *
25 * Google Author(s): Behdad Esfahbod
26 */
27
28#include "hb-test.h"
29
30/* Unit tests for complex text shaping */
31
32/*
33 * This test provides a framework to test aspects of hb_shape() that are
34 * font-dependent. Please add tests for any feature that fits that
35 * description.
36 */
37
Behdad Esfahboda346e922011-06-28 12:49:18 -040038#include <hb-ft.h>
Behdad Esfahboda346e922011-06-28 12:49:18 -040039
40typedef struct
41{
Behdad Esfahbod9704f0c2011-06-28 16:15:46 -040042 const char *font_file;
43 unsigned int face_index;
44 /* TODO add min/max face version */
45} font_data_t;
Behdad Esfahboda346e922011-06-28 12:49:18 -040046
Behdad Esfahbod42d453b2011-06-28 16:59:16 -040047static char *
48get_font_file (const font_data_t *font_data)
49{
50 return g_strdup_printf ("%s/fonts/%s", srcdir (), font_data->font_file);
51}
52
53
Behdad Esfahboda346e922011-06-28 12:49:18 -040054typedef struct
55{
Behdad Esfahbod9704f0c2011-06-28 16:15:46 -040056 char comments[64];
57 hb_codepoint_t characters[16];
58 hb_codepoint_t glyphs[16];
59} test_data_t;
60
61typedef struct
62{
63 const font_data_t font_data;
Behdad Esfahbod42d453b2011-06-28 16:59:16 -040064 const test_data_t test_datas[];
Behdad Esfahboda346e922011-06-28 12:49:18 -040065} test_set_t;
66
Behdad Esfahbod9704f0c2011-06-28 16:15:46 -040067typedef struct
68{
Behdad Esfahbod42d453b2011-06-28 16:59:16 -040069 const font_data_t *font_data;
70 const test_data_t *test_data;
Behdad Esfahbod9704f0c2011-06-28 16:15:46 -040071} test_t;
Behdad Esfahboda346e922011-06-28 12:49:18 -040072
Behdad Esfahbod27413162011-06-28 16:21:31 -040073
Behdad Esfahbod42d453b2011-06-28 16:59:16 -040074static const test_set_t tests_devanagari1 = {
Behdad Esfahbod9704f0c2011-06-28 16:15:46 -040075 {"raghu.ttf", 0},
Behdad Esfahboda346e922011-06-28 12:49:18 -040076 {
77 { "Ka",
78 { 0x0915, 0 },
79 { 0x0080, 0 }
80 },
81 { "Ka Halant",
82 { 0x0915, 0x094d, 0 },
83 { 0x0080, 0x0051, 0 }
84 },
85 { "Ka Halant Ka",
86 { 0x0915, 0x094d, 0x0915, 0 },
87 { 0x00c8, 0x0080, 0 }
88 },
89 { "Ka MatraI",
90 { 0x0915, 0x093f, 0 },
91 { 0x01d1, 0x0080, 0 }
92 },
93 { "Ra Halant Ka",
94 { 0x0930, 0x094d, 0x0915, 0 },
95 { 0x0080, 0x005b, 0 }
96 },
97 { "Ra Halant Ka MatraI",
98 { 0x0930, 0x094d, 0x0915, 0x093f, 0 },
99 { 0x01d1, 0x0080, 0x005b, 0 }
100 },
101 { "MatraI",
102 { 0x093f, 0 },
103 { 0x01d4, 0x029c, 0 }
104 },
105 { "Ka Nukta",
106 { 0x0915, 0x093c, 0 },
107 { 0x00a4, 0 }
108 },
109 { "Ka Halant Ra",
110 { 0x0915, 0x094d, 0x0930, 0 },
111 { 0x0110, 0 }
112 },
113 { "Ka Halant Ra Halant Ka",
114 { 0x0915, 0x094d, 0x0930, 0x094d, 0x0915, 0 },
115 { 0x0158, 0x0080, 0 }
116 },
117 { "",
118 { 0x0930, 0x094d, 0x200d, 0 },
119 { 0x00e2, 0 }
120 },
121 { "",
122 { 0x0915, 0x094d, 0x0930, 0x094d, 0x200d, 0 },
123 { 0x0158, 0 }
124 },
125 {{0}}
126 }
127};
128
Behdad Esfahbod42d453b2011-06-28 16:59:16 -0400129static const test_set_t tests_devanagari2 = {
Behdad Esfahbod9704f0c2011-06-28 16:15:46 -0400130 {"mangal.ttf", 0},
Behdad Esfahboda346e922011-06-28 12:49:18 -0400131 {
132 { "Ka",
133 { 0x0915, 0 },
134 { 0x0080, 0 }
135 },
136 { "Ka Halant",
137 { 0x0915, 0x094d, 0 },
138 { 0x0080, 0x0051, 0 }
139 },
140 { "Ka Halant Ka",
141 { 0x0915, 0x094d, 0x0915, 0 },
142 { 0x00c8, 0x0080, 0 }
143 },
144 { "Ka MatraI",
145 { 0x0915, 0x093f, 0 },
146 { 0x01d1, 0x0080, 0 }
147 },
148 { "Ra Halant Ka",
149 { 0x0930, 0x094d, 0x0915, 0 },
150 { 0x0080, 0x005b, 0 }
151 },
152 { "Ra Halant Ka MatraI",
153 { 0x0930, 0x094d, 0x0915, 0x093f, 0 },
154 { 0x01d1, 0x0080, 0x005b, 0 }
155 },
156 { "MatraI",
157 { 0x093f, 0 },
158 { 0x01d4, 0x029c, 0 }
159 },
160 { "Ka Nukta",
161 { 0x0915, 0x093c, 0 },
162 { 0x00a4, 0 }
163 },
164 { "Ka Halant Ra",
165 { 0x0915, 0x094d, 0x0930, 0 },
166 { 0x0110, 0 }
167 },
168 { "Ka Halant Ra Halant Ka",
169 { 0x0915, 0x094d, 0x0930, 0x094d, 0x0915, 0 },
170 { 0x0158, 0x0080, 0 }
171 },
172 { "",
173 { 0x92b, 0x94d, 0x930, 0 },
174 { 0x125, 0 }
175 },
176 { "",
177 { 0x92b, 0x93c, 0x94d, 0x930, 0 },
178 { 0x149, 0 }
179 },
180 {{0}}
181 }
182};
183
Behdad Esfahbod42d453b2011-06-28 16:59:16 -0400184static const test_set_t tests_bengali1 = {
Behdad Esfahbod9704f0c2011-06-28 16:15:46 -0400185 {"AkaashNormal.ttf", 0},
Behdad Esfahboda346e922011-06-28 12:49:18 -0400186 {
187 { "Ka",
188 { 0x0995, 0 },
189 { 0x0151, 0 }
190 },
191 { "Ka Halant",
192 { 0x0995, 0x09cd, 0 },
193 { 0x0151, 0x017d, 0 }
194 },
195 { "Ka Halant Ka",
196 { 0x0995, 0x09cd, 0x0995, 0 },
197 { 0x019b, 0 }
198 },
199 { "Ka MatraI",
200 { 0x0995, 0x09bf, 0 },
201 { 0x0173, 0x0151, 0 }
202 },
203 { "Ra Halant Ka",
204 { 0x09b0, 0x09cd, 0x0995, 0 },
205 { 0x0151, 0x0276, 0 }
206 },
207 { "Ra Halant Ka MatraI",
208 { 0x09b0, 0x09cd, 0x0995, 0x09bf, 0 },
209 { 0x0173, 0x0151, 0x0276, 0 }
210 },
211 { "Ka Nukta",
212 { 0x0995, 0x09bc, 0 },
213 { 0x0151, 0x0171, 0 }
214 },
215 { "Ka Halant Ra",
216 { 0x0995, 0x09cd, 0x09b0, 0 },
217 { 0x01f4, 0 }
218 },
219 { "Ka Halant Ra Halant Ka",
220 { 0x0995, 0x09cd, 0x09b0, 0x09cd, 0x0995, 0 },
221 { 0x025c, 0x0276, 0x0151, 0 }
222 },
223 { "Ya + Halant",
224 { 0x09af, 0x09cd, 0 },
225 { 0x016a, 0x017d, 0 }
226 },
227 { "Da Halant Ya -> Da Ya-Phala",
228 { 0x09a6, 0x09cd, 0x09af, 0 },
229 { 0x01e5, 0 }
230 },
231 { "A Halant Ya -> A Ya-phala",
232 { 0x0985, 0x09cd, 0x09af, 0 },
233 { 0x0145, 0x01cf, 0 }
234 },
235 { "Na Halant Ka",
236 { 0x09a8, 0x09cd, 0x0995, 0 },
237 { 0x026f, 0x0151, 0 }
238 },
239 { "Na Halant ZWNJ Ka",
240 { 0x09a8, 0x09cd, 0x200c, 0x0995, 0 },
241 { 0x0164, 0x017d, 0x0151, 0 }
242 },
243 { "Na Halant ZWJ Ka",
244 { 0x09a8, 0x09cd, 0x200d, 0x0995, 0 },
245 { 0x026f, 0x0151, 0 }
246 },
247 { "Ka Halant ZWNJ Ka",
248 { 0x0995, 0x09cd, 0x200c, 0x0995, 0 },
249 { 0x0151, 0x017d, 0x0151, 0 }
250 },
251 { "Ka Halant ZWJ Ka",
252 { 0x0995, 0x09cd, 0x200d, 0x0995, 0 },
253 { 0x025c, 0x0151, 0 }
254 },
255 { "Na Halant Ra",
256 { 0x09a8, 0x09cd, 0x09b0, 0 },
257 { 0x0207, 0 }
258 },
259 { "Na Halant ZWNJ Ra",
260 { 0x09a8, 0x09cd, 0x200c, 0x09b0, 0 },
261 { 0x0164, 0x017d, 0x016b, 0 }
262 },
263 { "Na Halant ZWJ Ra",
264 { 0x09a8, 0x09cd, 0x200d, 0x09b0, 0 },
265 { 0x026f, 0x016b, 0 }
266 },
267 { "Na Halant Ba",
268 { 0x09a8, 0x09cd, 0x09ac, 0 },
269 { 0x022f, 0 }
270 },
271 { "Na Halant ZWNJ Ba",
272 { 0x09a8, 0x09cd, 0x200c, 0x09ac, 0 },
273 { 0x0164, 0x017d, 0x0167, 0 }
274 },
275 { "Na Halant ZWJ Ba",
276 { 0x09a8, 0x09cd, 0x200d, 0x09ac, 0 },
277 { 0x026f, 0x0167, 0 }
278 },
279 { "Na Halant Dha",
280 { 0x09a8, 0x09cd, 0x09a7, 0 },
281 { 0x01d3, 0 }
282 },
283 { "Na Halant ZWNJ Dha",
284 { 0x09a8, 0x09cd, 0x200c, 0x09a7, 0 },
285 { 0x0164, 0x017d, 0x0163, 0 }
286 },
287 { "Na Halant ZWJ Dha",
288 { 0x09a8, 0x09cd, 0x200d, 0x09a7, 0 },
289 { 0x026f, 0x0163, 0 }
290 },
291 { "Ra Halant Ka MatraAU",
292 { 0x09b0, 0x09cd, 0x0995, 0x09cc, 0 },
293 { 0x0179, 0x0151, 0x0276, 0x017e, 0 }
294 },
295 { "Ra Halant Ba Halant Ba",
296 { 0x09b0, 0x09cd, 0x09ac, 0x09cd, 0x09ac, 0 },
297 { 0x0232, 0x0276, 0 }
298 },
299 { "",
300 { 0x9b0, 0x9cd, 0x995, 0x9be, 0x982, 0 },
301 { 0x151, 0x276, 0x172, 0x143, 0 }
302 },
303 { "",
304 { 0x9b0, 0x9cd, 0x995, 0x9be, 0x983, 0 },
305 { 0x151, 0x276, 0x172, 0x144, 0 }
306 },
307 /* Test decomposed two part matras */
308 { "",
309 { 0x995, 0x9c7, 0x9be, 0 },
310 { 0x179, 0x151, 0x172, 0 }
311 },
312 { "",
313 { 0x995, 0x9c7, 0x9d7, 0 },
314 { 0x179, 0x151, 0x17e, 0 }
315 },
316 { "",
317 { 0x9b0, 0x9cd, 0x9ad, 0 },
318 { 0x168, 0x276, 0 }
319 },
320 { "",
321 { 0x9f0, 0x9cd, 0x9ad, 0 },
322 { 0x168, 0x276, 0 }
323 },
324 { "",
325 { 0x9f1, 0x9cd, 0x9ad, 0 },
326 { 0x191, 0x17d, 0x168, 0 }
327 },
328 {{0}}
329 }
330};
331
Behdad Esfahbod42d453b2011-06-28 16:59:16 -0400332static const test_set_t tests_bengali2 = {
Behdad Esfahbod9704f0c2011-06-28 16:15:46 -0400333 {"MuktiNarrow.ttf", 0},
Behdad Esfahboda346e922011-06-28 12:49:18 -0400334 {
335 { "Ka",
336 { 0x0995, 0 },
337 { 0x0073, 0 }
338 },
339 { "Ka Halant",
340 { 0x0995, 0x09cd, 0 },
341 { 0x00b9, 0 }
342 },
343 { "Ka Halant Ka",
344 { 0x0995, 0x09cd, 0x0995, 0 },
345 { 0x0109, 0 }
346 },
347 { "Ka MatraI",
348 { 0x0995, 0x09bf, 0 },
349 { 0x0095, 0x0073, 0 }
350 },
351 { "Ra Halant Ka",
352 { 0x09b0, 0x09cd, 0x0995, 0 },
353 { 0x0073, 0x00e1, 0 }
354 },
355 { "Ra Halant Ka MatraI",
356 { 0x09b0, 0x09cd, 0x0995, 0x09bf, 0 },
357 { 0x0095, 0x0073, 0x00e1, 0 }
358 },
359 { "MatraI",
360 { 0x09bf, 0 },
361 { 0x0095, 0x01c8, 0 }
362 },
363 { "Ka Nukta",
364 { 0x0995, 0x09bc, 0 },
365 { 0x0073, 0x0093, 0 }
366 },
367 { "Ka Halant Ra",
368 { 0x0995, 0x09cd, 0x09b0, 0 },
369 { 0x00e5, 0 }
370 },
371 { "Ka Halant Ra Halant Ka",
372 { 0x995, 0x9cd, 0x9b0, 0x9cd, 0x995, 0 },
373 { 0x234, 0x24e, 0x73, 0 }
374 },
375 { "Ya + Halant",
376 { 0x09af, 0x09cd, 0 },
377 { 0x00d2, 0 }
378 },
379 { "Da Halant Ya -> Da Ya-Phala",
380 { 0x09a6, 0x09cd, 0x09af, 0 },
381 { 0x0084, 0x00e2, 0 }
382 },
383 { "A Halant Ya -> A Ya-phala",
384 { 0x0985, 0x09cd, 0x09af, 0 },
385 { 0x0067, 0x00e2, 0 }
386 },
387 { "Na Halant Ka",
388 { 0x09a8, 0x09cd, 0x0995, 0 },
389 { 0x0188, 0 }
390 },
391 { "Na Halant ZWNJ Ka",
392 { 0x9a8, 0x9cd, 0x200c, 0x995, 0 },
393 { 0xcc, 0x73, 0 }
394 },
395 { "Na Halant ZWJ Ka",
396 { 0x9a8, 0x9cd, 0x200d, 0x995, 0 },
397 { 0x247, 0x73, 0 }
398 },
399 { "Ka Halant ZWNJ Ka",
400 { 0x9a8, 0x9cd, 0x200d, 0x995, 0 },
401 { 0x247, 0x73, 0 }
402 },
403 { "Ka Halant ZWJ Ka",
404 { 0x9a8, 0x9cd, 0x200d, 0x995, 0 },
405 { 0x247, 0x73, 0 }
406 },
407 { "Na Halant Ra",
408 { 0x09a8, 0x09cd, 0x09b0, 0 },
409 { 0x00f8, 0 }
410 },
411 { "Na Halant ZWNJ Ra",
412 { 0x09a8, 0x09cd, 0x200c, 0x09b0, 0 },
413 { 0xcc, 0x8d, 0 }
414 },
415 { "Na Halant ZWJ Ra",
416 { 0x9a8, 0x9cd, 0x200d, 0x9b0, 0 },
417 { 0x247, 0x8d, 0 }
418 },
419 { "Na Halant Ba",
420 { 0x09a8, 0x09cd, 0x09ac, 0 },
421 { 0x0139, 0 }
422 },
423 { "Na Halant ZWNJ Ba",
424 { 0x9a8, 0x9cd, 0x200c, 0x9ac, 0 },
425 { 0xcc, 0x89, 0 }
426 },
427 { "Na Halant ZWJ Ba",
428 { 0x9a8, 0x9cd, 0x200d, 0x9ac, 0 },
429 { 0x247, 0x89, 0 }
430 },
431 { "Na Halant Dha",
432 { 0x09a8, 0x09cd, 0x09a7, 0 },
433 { 0x0145, 0 }
434 },
435 { "Na Halant ZWNJ Dha",
436 { 0x09a8, 0x09cd, 0x200c, 0x09a7, 0 },
437 { 0xcc, 0x85, 0 }
438 },
439 { "Na Halant ZWJ Dha",
440 { 0x09a8, 0x09cd, 0x200d, 0x09a7, 0 },
441 { 0x247, 0x85, 0 }
442 },
443 { "Ra Halant Ka MatraAU",
444 { 0x9b0, 0x9cd, 0x995, 0x9cc, 0 },
445 { 0x232, 0x73, 0xe1, 0xa0, 0 }
446 },
447 { "Ra Halant Ba Halant Ba",
448 { 0x09b0, 0x09cd, 0x09ac, 0x09cd, 0x09ac, 0 },
449 { 0x013b, 0x00e1, 0 }
450 },
451 {{0}}
452 }
453};
454
Behdad Esfahbod42d453b2011-06-28 16:59:16 -0400455static const test_set_t tests_bengali3 = {
Behdad Esfahbod9704f0c2011-06-28 16:15:46 -0400456 {"LikhanNormal.ttf", 0},
Behdad Esfahboda346e922011-06-28 12:49:18 -0400457 {
458 { "",
459 { 0x09a8, 0x09cd, 0x09af, 0 },
460 { 0x01ca, 0 }
461 },
462 { "",
463 { 0x09b8, 0x09cd, 0x09af, 0 },
464 { 0x020e, 0 }
465 },
466 { "",
467 { 0x09b6, 0x09cd, 0x09af, 0 },
468 { 0x01f4, 0 }
469 },
470 { "",
471 { 0x09b7, 0x09cd, 0x09af, 0 },
472 { 0x01fe, 0 }
473 },
474 { "",
475 { 0x09b0, 0x09cd, 0x09a8, 0x09cd, 0x200d, 0 },
476 { 0x10b, 0x167, 0 }
477 },
478 { "",
479 { 0x9b0, 0x9cd, 0x9ad, 0 },
480 { 0xa1, 0x167, 0 }
481 },
482 { "",
483 { 0x9f0, 0x9cd, 0x9ad, 0 },
484 { 0xa1, 0x167, 0 }
485 },
486 { "",
487 { 0x9f1, 0x9cd, 0x9ad, 0 },
488 { 0x11c, 0xa1, 0 }
489 },
490 {{0}}
491 }
492};
493
494static const test_set_t tests_gurmukhi = {
Behdad Esfahbod9704f0c2011-06-28 16:15:46 -0400495 {"lohit_pa.ttf", 0},
Behdad Esfahboda346e922011-06-28 12:49:18 -0400496 {
497 { "",
498 { 0xA15, 0xA4D, 0xa39, 0 },
499 { 0x3b, 0x8b, 0 }
500 },
501 {{0}}
502 }
503};
504
505static const test_set_t tests_oriya = {
Behdad Esfahbod9704f0c2011-06-28 16:15:46 -0400506 {"utkalm.ttf", 0},
Behdad Esfahboda346e922011-06-28 12:49:18 -0400507 {
508 { "",
509 { 0xb15, 0xb4d, 0xb24, 0xb4d, 0xb30, 0 },
510 { 0x150, 0x125, 0 }
511 },
512 { "",
513 { 0xb24, 0xb4d, 0xb24, 0xb4d, 0xb2c, 0 },
514 { 0x151, 0x120, 0 }
515 },
516 { "",
517 { 0xb28, 0xb4d, 0xb24, 0xb4d, 0xb2c, 0 },
518 { 0x152, 0x120, 0 }
519 },
520 { "",
521 { 0xb28, 0xb4d, 0xb24, 0xb4d, 0xb2c, 0 },
522 { 0x152, 0x120, 0 }
523 },
524 { "",
525 { 0xb28, 0xb4d, 0xb24, 0xb4d, 0xb30, 0 },
526 { 0x176, 0 }
527 },
528 { "",
529 { 0xb38, 0xb4d, 0xb24, 0xb4d, 0xb30, 0 },
530 { 0x177, 0 }
531 },
532 { "",
533 { 0xb28, 0xb4d, 0xb24, 0xb4d, 0xb30, 0xb4d, 0xb2f, 0 },
534 { 0x176, 0x124, 0 }
535 },
536 {{0}}
537 }
538};
539
540static const test_set_t tests_tamil = {
Behdad Esfahbod9704f0c2011-06-28 16:15:46 -0400541 {"akruti1.ttf", 0},
Behdad Esfahboda346e922011-06-28 12:49:18 -0400542 {
543 { "",
544 { 0x0b95, 0x0bc2, 0 },
545 { 0x004e, 0 }
546 },
547 { "",
548 { 0x0bae, 0x0bc2, 0 },
549 { 0x009e, 0 }
550 },
551 { "",
552 { 0x0b9a, 0x0bc2, 0 },
553 { 0x0058, 0 }
554 },
555 { "",
556 { 0x0b99, 0x0bc2, 0 },
557 { 0x0053, 0 }
558 },
559 { "",
560 { 0x0bb0, 0x0bc2, 0 },
561 { 0x00a8, 0 }
562 },
563 { "",
564 { 0x0ba4, 0x0bc2, 0 },
565 { 0x008e, 0 }
566 },
567 { "",
568 { 0x0b9f, 0x0bc2, 0 },
569 { 0x0062, 0 }
570 },
571 { "",
572 { 0x0b95, 0x0bc6, 0 },
573 { 0x000a, 0x0031, 0 }
574 },
575 { "",
576 { 0x0b95, 0x0bca, 0 },
577 { 0x000a, 0x0031, 0x0007, 0 }
578 },
579 { "",
580 { 0x0b95, 0x0bc6, 0x0bbe, 0 },
581 { 0x000a, 0x0031, 0x007, 0 }
582 },
583 { "",
584 { 0x0b95, 0x0bcd, 0x0bb7, 0 },
585 { 0x0049, 0 }
586 },
587 { "",
588 { 0x0b95, 0x0bcd, 0x0bb7, 0x0bca, 0 },
589 { 0x000a, 0x0049, 0x007, 0 }
590 },
591 { "",
592 { 0x0b95, 0x0bcd, 0x0bb7, 0x0bc6, 0x0bbe, 0 },
593 { 0x000a, 0x0049, 0x007, 0 }
594 },
595 { "",
596 { 0x0b9f, 0x0bbf, 0 },
597 { 0x005f, 0 }
598 },
599 { "",
600 { 0x0b9f, 0x0bc0, 0 },
601 { 0x0060, 0 }
602 },
603 { "",
604 { 0x0bb2, 0x0bc0, 0 },
605 { 0x00ab, 0 }
606 },
607 { "",
608 { 0x0bb2, 0x0bbf, 0 },
609 { 0x00aa, 0 }
610 },
611 { "",
612 { 0x0bb0, 0x0bcd, 0 },
613 { 0x00a4, 0 }
614 },
615 { "",
616 { 0x0bb0, 0x0bbf, 0 },
617 { 0x00a5, 0 }
618 },
619 { "",
620 { 0x0bb0, 0x0bc0, 0 },
621 { 0x00a6, 0 }
622 },
623 { "",
624 { 0x0b83, 0 },
625 { 0x0025, 0 }
626 },
627 { "",
628 { 0x0b83, 0x0b95, 0 },
629 { 0x0025, 0x0031, 0 }
630 },
631 {{0}}
632 }
633};
634
635static const test_set_t tests_telugu = {
Behdad Esfahbod9704f0c2011-06-28 16:15:46 -0400636 {"Pothana2000.ttf", 0},
Behdad Esfahboda346e922011-06-28 12:49:18 -0400637 {
638 { "",
639 { 0xc15, 0xc4d, 0 },
640 { 0xbb, 0 }
641 },
642 { "",
643 { 0xc15, 0xc4d, 0xc37, 0 },
644 { 0x4b, 0 }
645 },
646 { "",
647 { 0xc15, 0xc4d, 0xc37, 0xc4d, 0 },
648 { 0xe0, 0 }
649 },
650 { "",
651 { 0xc15, 0xc4d, 0xc37, 0xc4d, 0xc23, 0 },
652 { 0x4b, 0x91, 0 }
653 },
654 { "",
655 { 0xc15, 0xc4d, 0xc30, 0 },
656 { 0x5a, 0xb2, 0 }
657 },
658 { "",
659 { 0xc15, 0xc4d, 0xc30, 0xc4d, 0 },
660 { 0xbb, 0xb2, 0 }
661 },
662 { "",
663 { 0xc15, 0xc4d, 0xc30, 0xc4d, 0xc15, 0 },
664 { 0x5a, 0xb2, 0x83, 0 }
665 },
666 { "",
667 { 0xc15, 0xc4d, 0xc30, 0xc3f, 0 },
668 { 0xe2, 0xb2, 0 }
669 },
670 { "",
671 { 0xc15, 0xc4d, 0xc15, 0xc48, 0 },
672 { 0xe6, 0xb3, 0x83, 0 }
673 },
674 { "",
675 { 0xc15, 0xc4d, 0xc30, 0xc48, 0 },
676 { 0xe6, 0xb3, 0x9f, 0 }
677 },
678 { "",
679 { 0xc15, 0xc46, 0xc56, 0 },
680 { 0xe6, 0xb3, 0 }
681 },
682 {{0}}
683 }
684};
685
Behdad Esfahbod42d453b2011-06-28 16:59:16 -0400686static const test_set_t tests_kannada1 = {
Behdad Esfahbod9704f0c2011-06-28 16:15:46 -0400687 {"Sampige.ttf", 0},
Behdad Esfahboda346e922011-06-28 12:49:18 -0400688 {
689 { "",
690 { 0x0ca8, 0x0ccd, 0x0ca8, 0 },
691 { 0x0049, 0x00ba, 0 }
692 },
693 { "",
694 { 0x0ca8, 0x0ccd, 0x0ca1, 0 },
695 { 0x0049, 0x00b3, 0 }
696 },
697 { "",
698 { 0x0caf, 0x0cc2, 0 },
699 { 0x004f, 0x005d, 0 }
700 },
701 { "",
702 { 0x0ce0, 0 },
703 { 0x006a, 0 }
704 },
705 { "",
706 { 0x0ce6, 0x0ce7, 0x0ce8, 0 },
707 { 0x006b, 0x006c, 0x006d, 0 }
708 },
709 { "",
710 { 0x0cb5, 0x0ccb, 0 },
711 { 0x015f, 0x0067, 0 }
712 },
713 { "",
714 { 0x0cb0, 0x0ccd, 0x0cae, 0 },
715 { 0x004e, 0x0082, 0 }
716 },
717 { "",
718 { 0x0cb0, 0x0ccd, 0x0c95, 0 },
719 { 0x0036, 0x0082, 0 }
720 },
721 { "",
722 { 0x0c95, 0x0ccd, 0x0cb0, 0 },
723 { 0x0036, 0x00c1, 0 }
724 },
725 { "",
726 { 0x0cb0, 0x0ccd, 0x200d, 0x0c95, 0 },
727 { 0x0050, 0x00a7, 0 }
728 },
729 {{0}}
730 }
731};
732
Behdad Esfahbod42d453b2011-06-28 16:59:16 -0400733static const test_set_t tests_kannada2 = {
Behdad Esfahbod9704f0c2011-06-28 16:15:46 -0400734 {"tunga.ttf", 0},
Behdad Esfahboda346e922011-06-28 12:49:18 -0400735 {
736 { "",
737 { 0x0cb7, 0x0cc6, 0 },
738 { 0x00b0, 0x006c, 0 }
739 },
740 { "",
741 { 0x0cb7, 0x0ccd, 0 },
742 { 0x0163, 0 }
743 },
744 { "",
745 { 0xc95, 0xcbf, 0xcd5, 0 },
746 { 0x114, 0x73, 0 }
747 },
748 { "",
749 { 0xc95, 0xcc6, 0xcd5, 0 },
750 { 0x90, 0x6c, 0x73, 0 }
751 },
752 { "",
753 { 0xc95, 0xcc6, 0xcd6, 0 },
754 { 0x90, 0x6c, 0x74, 0 }
755 },
756 { "",
757 { 0xc95, 0xcc6, 0xcc2, 0 },
758 { 0x90, 0x6c, 0x69, 0 }
759 },
760 { "",
761 { 0xc95, 0xcca, 0xcd5, 0 },
762 { 0x90, 0x6c, 0x69, 0x73, 0 }
763 },
764 {{0}}
765 }
766};
767
Behdad Esfahbod42d453b2011-06-28 16:59:16 -0400768static const test_set_t tests_malayalam1 = {
Behdad Esfahbod9704f0c2011-06-28 16:15:46 -0400769 {"AkrutiMal2Normal.ttf", 0},
Behdad Esfahboda346e922011-06-28 12:49:18 -0400770 {
771 { "",
772 { 0x0d15, 0x0d46, 0 },
773 { 0x005e, 0x0034, 0 }
774 },
775 { "",
776 { 0x0d15, 0x0d47, 0 },
777 { 0x005f, 0x0034, 0 }
778 },
779 { "",
780 { 0x0d15, 0x0d4b, 0 },
781 { 0x005f, 0x0034, 0x0058, 0 }
782 },
783 { "",
784 { 0x0d15, 0x0d48, 0 },
785 { 0x0060, 0x0034, 0 }
786 },
787 { "",
788 { 0x0d15, 0x0d4a, 0 },
789 { 0x005e, 0x0034, 0x0058, 0 }
790 },
791 { "",
792 { 0x0d30, 0x0d4d, 0x0d15, 0 },
793 { 0x009e, 0x0034, 0 }
794 },
795 { "",
796 { 0x0d15, 0x0d4d, 0x0d35, 0 },
797 { 0x0034, 0x007a, 0 }
798 },
799 { "",
800 { 0x0d15, 0x0d4d, 0x0d2f, 0 },
801 { 0x0034, 0x00a2, 0 }
802 },
803 { "",
804 { 0x0d1f, 0x0d4d, 0x0d1f, 0 },
805 { 0x0069, 0 }
806 },
807 { "",
808 { 0x0d26, 0x0d4d, 0x0d26, 0 },
809 { 0x0074, 0 }
810 },
811 { "",
812 { 0x0d30, 0x0d4d, 0 },
813 { 0x009e, 0 }
814 },
815 { "",
816 { 0x0d30, 0x0d4d, 0x200c, 0 },
817 { 0x009e, 0 }
818 },
819 { "",
820 { 0x0d30, 0x0d4d, 0x200d, 0 },
821 { 0x009e, 0 }
822 },
823 { "",
824 { 0xd15, 0xd46, 0xd3e, 0 },
825 { 0x5e, 0x34, 0x58, 0 }
826 },
827 { "",
828 { 0xd15, 0xd47, 0xd3e, 0 },
829 { 0x5f, 0x34, 0x58, 0 }
830 },
831 { "",
832 { 0xd15, 0xd46, 0xd57, 0 },
833 { 0x5e, 0x34, 0x65, 0 }
834 },
835 { "",
836 { 0xd15, 0xd57, 0 },
837 { 0x34, 0x65, 0 }
838 },
839 { "",
840 { 0xd1f, 0xd4d, 0xd1f, 0xd41, 0xd4d, 0 },
841 { 0x69, 0x5b, 0x64, 0 }
842 },
843
844 {{0}}
845 }
846};
847
Behdad Esfahbod42d453b2011-06-28 16:59:16 -0400848static const test_set_t tests_malayalam2 = {
Behdad Esfahbod9704f0c2011-06-28 16:15:46 -0400849 {"Rachana.ttf", 0},
Behdad Esfahboda346e922011-06-28 12:49:18 -0400850 {
851 { "",
852 { 0xd37, 0xd4d, 0xd1f, 0xd4d, 0xd30, 0xd40, 0 },
853 { 0x385, 0xa3, 0 }
854 },
855 { "",
856 { 0xd2f, 0xd4d, 0xd15, 0xd4d, 0xd15, 0xd41, 0 },
857 { 0x2ff, 0 }
858 },
859 { "",
860 { 0xd33, 0xd4d, 0xd33, 0 },
861 { 0x3f8, 0 }
862 },
863 { "",
864 { 0xd2f, 0xd4d, 0xd15, 0xd4d, 0xd15, 0xd41, 0 },
865 { 0x2ff, 0 }
866 },
867 { "",
868 { 0xd30, 0xd4d, 0x200d, 0xd35, 0xd4d, 0xd35, 0 },
869 { 0xf3, 0x350, 0 }
870 },
871
872 {{0}}
873 }
874};
875
876static const test_set_t tests_sinhala = {
Behdad Esfahbod9704f0c2011-06-28 16:15:46 -0400877 {"FM-MalithiUW46.ttf", 0},
Behdad Esfahboda346e922011-06-28 12:49:18 -0400878 {
879 { "",
880 { 0xd9a, 0xdd9, 0xdcf, 0 },
881 { 0x4a, 0x61, 0x42, 0 }
882 },
883 { "",
884 { 0xd9a, 0xdd9, 0xddf, 0 },
885 { 0x4a, 0x61, 0x50, 0 }
886 },
887 { "",
888 { 0xd9a, 0xdd9, 0xdca, 0 },
889 { 0x4a, 0x62, 0 }
890 },
891 { "",
892 { 0xd9a, 0xddc, 0xdca, 0 },
893 { 0x4a, 0x61, 0x42, 0x41, 0 }
894 },
895 { "",
896 { 0xd9a, 0xdda, 0 },
897 { 0x4a, 0x62, 0 }
898 },
899 { "",
900 { 0xd9a, 0xddd, 0 },
901 { 0x4a, 0x61, 0x42, 0x41, 0 }
902 },
903 {{0}}
904 }
905};
906
907static const test_set_t tests_khmer = {
Behdad Esfahbod9704f0c2011-06-28 16:15:46 -0400908 {"KhmerOS.ttf", 0},
Behdad Esfahboda346e922011-06-28 12:49:18 -0400909 {
910 { "",
911 { 0x179a, 0x17cd, 0 },
912 { 0x24c, 0x27f, 0 }
913 },
914 { "",
915 { 0x179f, 0x17c5, 0 },
916 { 0x273, 0x203, 0 }
917 },
918 { "",
919 { 0x1790, 0x17d2, 0x1784, 0x17c3, 0 },
920 { 0x275, 0x242, 0x182, 0 }
921 },
922 { "",
923 { 0x179a, 0 },
924 { 0x24c, 0 }
925 },
926 { "",
927 { 0x1781, 0x17d2, 0x1798, 0x17c2, 0 },
928 { 0x274, 0x233, 0x197, 0 }
929 },
930 { "",
931 { 0x1798, 0x17b6, 0 },
932 { 0x1cb, 0 }
933 },
934 { "",
935 { 0x179a, 0x17b8, 0 },
936 { 0x24c, 0x26a, 0 }
937 },
938 { "",
939 { 0x1787, 0x17b6, 0 },
940 { 0x1ba, 0 }
941 },
942 { "",
943 { 0x1798, 0x17d2, 0x1796, 0x17bb, 0 },
944 { 0x24a, 0x195, 0x26d, 0 }
945 },
946 {{0}}
947 }
948};
949
950static const test_set_t tests_nko = {
Behdad Esfahbod9704f0c2011-06-28 16:15:46 -0400951 {"DejaVuSans.ttf", 0},
Behdad Esfahboda346e922011-06-28 12:49:18 -0400952 {
953 { "",
954 { 0x7ca, 0 },
955 { 0x5c1, 0 }
956 },
957 { "",
958 { 0x7ca, 0x7ca, 0 },
Behdad Esfahbod86131932011-07-30 20:21:40 -0400959 { 0x14d9, 0x14db, 0 }
Behdad Esfahboda346e922011-06-28 12:49:18 -0400960 },
961 { "",
962 { 0x7ca, 0x7fa, 0x7ca, 0 },
Behdad Esfahbod86131932011-07-30 20:21:40 -0400963 { 0x14d9, 0x5ec, 0x14db, 0 }
Behdad Esfahboda346e922011-06-28 12:49:18 -0400964 },
965 { "",
966 { 0x7ca, 0x7f3, 0x7ca, 0 },
Behdad Esfahbod86131932011-07-30 20:21:40 -0400967 { 0x14d9, 0x5e7, 0x14db, 0 }
Behdad Esfahboda346e922011-06-28 12:49:18 -0400968 },
969 { "",
970 { 0x7ca, 0x7f3, 0x7fa, 0x7ca, 0 },
Behdad Esfahbod86131932011-07-30 20:21:40 -0400971 { 0x14d9, 0x5ec, 0x5e7, 0x14db, 0 }
Behdad Esfahboda346e922011-06-28 12:49:18 -0400972 },
973 {{0}}
974 }
975};
976
977static const test_set_t tests_linearb = {
Behdad Esfahbod9704f0c2011-06-28 16:15:46 -0400978 {"penuture.ttf", 0},
Behdad Esfahboda346e922011-06-28 12:49:18 -0400979 {
980 { "",
981 { 0xd800, 0xdc01, 0xd800, 0xdc02, 0xd800, 0xdc03, 0 },
982 { 0x5, 0x6, 0x7, 0 },
983 },
984 {{0}}
985 }
986};
987
988
989
Behdad Esfahbod42d453b2011-06-28 16:59:16 -0400990
991
Behdad Esfahboda346e922011-06-28 12:49:18 -0400992typedef struct {
993 FT_Library ft_library;
994 FT_Face ft_face;
995 hb_font_t *font;
996} ft_fixture_t;
997
998static void
999ft_fixture_init (ft_fixture_t *f, gconstpointer user_data)
1000{
Behdad Esfahbod42d453b2011-06-28 16:59:16 -04001001 const test_t *test = user_data;
1002 char *font_file = get_font_file (test->font_data);
1003 FT_Error err;
Behdad Esfahboda346e922011-06-28 12:49:18 -04001004
1005 FT_Init_FreeType (&f->ft_library);
1006
Behdad Esfahbod42d453b2011-06-28 16:59:16 -04001007 err = FT_New_Face (f->ft_library, font_file, test->font_data->face_index, &f->ft_face);
1008 g_assert_cmpint (err, ==, 0);
1009
1010 f->font = hb_ft_font_create (f->ft_face, NULL);
Behdad Esfahboda346e922011-06-28 12:49:18 -04001011
1012 g_free (font_file);
1013}
1014
1015static void
1016ft_fixture_finish (ft_fixture_t *f, gconstpointer user_data)
1017{
1018 hb_font_destroy (f->font);
1019
1020 FT_Done_Face (f->ft_face);
1021 FT_Done_FreeType (f->ft_library);
1022}
1023
1024static void
1025test_shape_complex (ft_fixture_t *f, gconstpointer user_data)
1026{
Behdad Esfahbod42d453b2011-06-28 16:59:16 -04001027 const test_t *test = user_data;
1028 const test_data_t *data = test->test_data;
1029 hb_buffer_t *buffer;
1030 unsigned int i, len, expected_len;
1031 hb_glyph_info_t *glyphs;
Behdad Esfahbodafa74bf2011-06-28 17:25:17 -04001032 hb_bool_t fail;
Behdad Esfahbod07cedd82011-07-30 21:16:51 -04001033 GString *str;
Behdad Esfahboda346e922011-06-28 12:49:18 -04001034
Behdad Esfahbod42d453b2011-06-28 16:59:16 -04001035 g_assert (f->font);
Behdad Esfahboda346e922011-06-28 12:49:18 -04001036
Behdad Esfahbod42d453b2011-06-28 16:59:16 -04001037 if (data->comments[0])
1038 g_test_message ("Test comments: %s", data->comments);
Behdad Esfahboda346e922011-06-28 12:49:18 -04001039
Behdad Esfahbod42d453b2011-06-28 16:59:16 -04001040 buffer = hb_buffer_create (0);
1041 for (len = 0; data->characters[len]; len++) ;
1042 hb_buffer_add_utf32 (buffer, data->characters, len, 0, len);
Behdad Esfahboda346e922011-06-28 12:49:18 -04001043
Behdad Esfahbod42d453b2011-06-28 16:59:16 -04001044 hb_shape (f->font, buffer, NULL, 0);
Behdad Esfahboda346e922011-06-28 12:49:18 -04001045
Behdad Esfahbod42d453b2011-06-28 16:59:16 -04001046 for (len = 0; data->glyphs[len]; len++) ;
1047 expected_len = len;
Behdad Esfahboda346e922011-06-28 12:49:18 -04001048
Behdad Esfahbod42d453b2011-06-28 16:59:16 -04001049 glyphs = hb_buffer_get_glyph_infos (buffer, &len);
Behdad Esfahbodafa74bf2011-06-28 17:25:17 -04001050 fail = len != expected_len;
1051 if (!fail)
1052 for (i = 0; i < len; i++)
1053 if (glyphs[i].codepoint != data->glyphs[i]) {
1054 fail = TRUE;
1055 break;
1056 }
1057
Behdad Esfahbod07cedd82011-07-30 21:16:51 -04001058 str = g_string_new ("");
1059 for (i = 0; i < len; i++)
1060 g_string_append_printf (str, " %4d", glyphs[i].codepoint);
1061 g_test_message ("Received glyphs: %s", str->str);
1062 g_string_truncate (str, 0);
1063 for (i = 0; i < expected_len; i++)
1064 g_string_append_printf (str, " %4d", data->glyphs[i]);
1065 g_test_message ("Expected glyphs: %s", str->str);
1066 g_string_free (str, TRUE);
Behdad Esfahbodafa74bf2011-06-28 17:25:17 -04001067
Behdad Esfahbod07cedd82011-07-30 21:16:51 -04001068 if (fail) {
Behdad Esfahbod1a1b5012011-07-29 16:36:46 -04001069 g_test_message ("FAIL");
1070 /* The glib test framework is useless, lets not fail for now,
1071 * we can grep for FAIL/PASS and count manually. Sigh... */
1072 /*g_test_fail ();*/
1073 } else
1074 g_test_message ("PASS");
Behdad Esfahboda346e922011-06-28 12:49:18 -04001075
Behdad Esfahbod42d453b2011-06-28 16:59:16 -04001076 hb_buffer_destroy (buffer);
Behdad Esfahboda346e922011-06-28 12:49:18 -04001077}
1078
Behdad Esfahbod42d453b2011-06-28 16:59:16 -04001079static void
1080test_shape_complex_skipped (gconstpointer user_data)
1081{
1082 const test_t *test = user_data;
1083 const test_data_t *data = test->test_data;
1084
1085 if (data->comments[0])
1086 g_test_message ("Test comments: %s", data->comments);
1087
1088 g_test_message ("Skipping test");
1089}
Behdad Esfahboda346e922011-06-28 12:49:18 -04001090
1091
Behdad Esfahbod27413162011-06-28 16:21:31 -04001092static void
1093add_test_set (const test_set_t *test_set, const char *set_name)
1094{
Behdad Esfahbod42d453b2011-06-28 16:59:16 -04001095 const test_data_t *data;
1096 char *font_file;
1097 hb_bool_t skip;
Behdad Esfahbod27413162011-06-28 16:21:31 -04001098
Behdad Esfahbod42d453b2011-06-28 16:59:16 -04001099 font_file = get_font_file (&test_set->font_data);
1100 skip = !g_file_test (font_file, G_FILE_TEST_EXISTS);
1101 g_free (font_file);
1102
1103 for (data = test_set->test_datas; data->characters[0]; data++) {
1104 char *flavor;
1105 GString *str;
1106 const hb_codepoint_t *p;
1107
1108 test_t *test = g_slice_new0 (test_t);
1109 test->font_data = &test_set->font_data;
1110 test->test_data = data;
1111
1112 str = g_string_new ("<");
1113 for (p = data->characters; *p; p++)
1114 g_string_append_printf (str, "%04X,", *p);
1115 str->str[str->len - 1] = '>';
1116
Behdad Esfahboddd5546d2011-07-29 16:27:31 -04001117 flavor = g_strdup_printf ("%s/%s/%ld:%s", set_name, test_set->font_data.font_file, data - test_set->test_datas, str->str);
Behdad Esfahbod42d453b2011-06-28 16:59:16 -04001118
1119 g_string_free (str, TRUE);
1120
1121 if (skip)
1122 hb_test_add_data_flavor ((const void *) test, flavor, test_shape_complex_skipped);
1123 else
1124 hb_test_add_fixture_flavor (ft_fixture, (const void *) test, flavor, test_shape_complex);
1125
1126 g_free (flavor);
1127 }
Behdad Esfahbod27413162011-06-28 16:21:31 -04001128}
1129
Behdad Esfahboda346e922011-06-28 12:49:18 -04001130
1131int
1132main (int argc, char **argv)
1133{
1134 hb_test_init (&argc, &argv);
1135
Behdad Esfahbod27413162011-06-28 16:21:31 -04001136#define TEST_SET(name) add_test_set (&tests_##name, #name)
Behdad Esfahboda346e922011-06-28 12:49:18 -04001137
Behdad Esfahbod42d453b2011-06-28 16:59:16 -04001138 TEST_SET (devanagari1);
1139 TEST_SET (devanagari2);
1140 TEST_SET (bengali1);
1141 TEST_SET (bengali2);
1142 TEST_SET (bengali3);
Behdad Esfahboda346e922011-06-28 12:49:18 -04001143 TEST_SET (gurmukhi);
1144 TEST_SET (oriya);
1145 TEST_SET (tamil);
1146 TEST_SET (telugu);
Behdad Esfahbod42d453b2011-06-28 16:59:16 -04001147 TEST_SET (kannada1);
1148 TEST_SET (kannada2);
1149 TEST_SET (malayalam1);
1150 TEST_SET (malayalam2);
Behdad Esfahboda346e922011-06-28 12:49:18 -04001151 TEST_SET (sinhala);
1152
1153 TEST_SET (khmer);
1154
1155 TEST_SET (nko);
1156 TEST_SET (linearb);
1157
1158 return hb_test_run();
1159}