2 * Copyright © 2011 Google, Inc.
3 * Copyright © 2008 Nokia Corporation and/or its subsidiary(-ies)
5 * This is part of HarfBuzz, a text shaping library.
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.
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
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.
25 * Google Author(s): Behdad Esfahbod
30 /* Unit tests for complex text shaping */
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
42 const char *font_file;
43 unsigned int face_index;
44 /* TODO add min/max face version */
48 get_font_file (const font_data_t *font_data)
50 return g_strdup_printf ("%s/fonts/%s", srcdir (), font_data->font_file);
57 hb_codepoint_t characters[16];
58 hb_codepoint_t glyphs[16];
63 const font_data_t font_data;
64 const test_data_t test_datas[];
69 const font_data_t *font_data;
70 const test_data_t *test_data;
74 static const test_set_t tests_devanagari1 = {
82 { 0x0915, 0x094d, 0 },
86 { 0x0915, 0x094d, 0x0915, 0 },
90 { 0x0915, 0x093f, 0 },
94 { 0x0930, 0x094d, 0x0915, 0 },
97 { "Ra Halant Ka MatraI",
98 { 0x0930, 0x094d, 0x0915, 0x093f, 0 },
99 { 0x01d1, 0x0080, 0x005b, 0 }
103 { 0x01d4, 0x029c, 0 }
106 { 0x0915, 0x093c, 0 },
110 { 0x0915, 0x094d, 0x0930, 0 },
113 { "Ka Halant Ra Halant Ka",
114 { 0x0915, 0x094d, 0x0930, 0x094d, 0x0915, 0 },
115 { 0x0158, 0x0080, 0 }
118 { 0x0930, 0x094d, 0x200d, 0 },
122 { 0x0915, 0x094d, 0x0930, 0x094d, 0x200d, 0 },
129 static const test_set_t tests_devanagari2 = {
137 { 0x0915, 0x094d, 0 },
138 { 0x0080, 0x0051, 0 }
141 { 0x0915, 0x094d, 0x0915, 0 },
142 { 0x00c8, 0x0080, 0 }
145 { 0x0915, 0x093f, 0 },
146 { 0x01d1, 0x0080, 0 }
149 { 0x0930, 0x094d, 0x0915, 0 },
150 { 0x0080, 0x005b, 0 }
152 { "Ra Halant Ka MatraI",
153 { 0x0930, 0x094d, 0x0915, 0x093f, 0 },
154 { 0x01d1, 0x0080, 0x005b, 0 }
158 { 0x01d4, 0x029c, 0 }
161 { 0x0915, 0x093c, 0 },
165 { 0x0915, 0x094d, 0x0930, 0 },
168 { "Ka Halant Ra Halant Ka",
169 { 0x0915, 0x094d, 0x0930, 0x094d, 0x0915, 0 },
170 { 0x0158, 0x0080, 0 }
173 { 0x92b, 0x94d, 0x930, 0 },
177 { 0x92b, 0x93c, 0x94d, 0x930, 0 },
184 static const test_set_t tests_bengali1 = {
185 {"AkaashNormal.ttf", 0},
192 { 0x0995, 0x09cd, 0 },
193 { 0x0151, 0x017d, 0 }
196 { 0x0995, 0x09cd, 0x0995, 0 },
200 { 0x0995, 0x09bf, 0 },
201 { 0x0173, 0x0151, 0 }
204 { 0x09b0, 0x09cd, 0x0995, 0 },
205 { 0x0151, 0x0276, 0 }
207 { "Ra Halant Ka MatraI",
208 { 0x09b0, 0x09cd, 0x0995, 0x09bf, 0 },
209 { 0x0173, 0x0151, 0x0276, 0 }
212 { 0x0995, 0x09bc, 0 },
213 { 0x0151, 0x0171, 0 }
216 { 0x0995, 0x09cd, 0x09b0, 0 },
219 { "Ka Halant Ra Halant Ka",
220 { 0x0995, 0x09cd, 0x09b0, 0x09cd, 0x0995, 0 },
221 { 0x025c, 0x0276, 0x0151, 0 }
224 { 0x09af, 0x09cd, 0 },
225 { 0x016a, 0x017d, 0 }
227 { "Da Halant Ya -> Da Ya-Phala",
228 { 0x09a6, 0x09cd, 0x09af, 0 },
231 { "A Halant Ya -> A Ya-phala",
232 { 0x0985, 0x09cd, 0x09af, 0 },
233 { 0x0145, 0x01cf, 0 }
236 { 0x09a8, 0x09cd, 0x0995, 0 },
237 { 0x026f, 0x0151, 0 }
239 { "Na Halant ZWNJ Ka",
240 { 0x09a8, 0x09cd, 0x200c, 0x0995, 0 },
241 { 0x0164, 0x017d, 0x0151, 0 }
243 { "Na Halant ZWJ Ka",
244 { 0x09a8, 0x09cd, 0x200d, 0x0995, 0 },
245 { 0x026f, 0x0151, 0 }
247 { "Ka Halant ZWNJ Ka",
248 { 0x0995, 0x09cd, 0x200c, 0x0995, 0 },
249 { 0x0151, 0x017d, 0x0151, 0 }
251 { "Ka Halant ZWJ Ka",
252 { 0x0995, 0x09cd, 0x200d, 0x0995, 0 },
253 { 0x025c, 0x0151, 0 }
256 { 0x09a8, 0x09cd, 0x09b0, 0 },
259 { "Na Halant ZWNJ Ra",
260 { 0x09a8, 0x09cd, 0x200c, 0x09b0, 0 },
261 { 0x0164, 0x017d, 0x016b, 0 }
263 { "Na Halant ZWJ Ra",
264 { 0x09a8, 0x09cd, 0x200d, 0x09b0, 0 },
265 { 0x026f, 0x016b, 0 }
268 { 0x09a8, 0x09cd, 0x09ac, 0 },
271 { "Na Halant ZWNJ Ba",
272 { 0x09a8, 0x09cd, 0x200c, 0x09ac, 0 },
273 { 0x0164, 0x017d, 0x0167, 0 }
275 { "Na Halant ZWJ Ba",
276 { 0x09a8, 0x09cd, 0x200d, 0x09ac, 0 },
277 { 0x026f, 0x0167, 0 }
280 { 0x09a8, 0x09cd, 0x09a7, 0 },
283 { "Na Halant ZWNJ Dha",
284 { 0x09a8, 0x09cd, 0x200c, 0x09a7, 0 },
285 { 0x0164, 0x017d, 0x0163, 0 }
287 { "Na Halant ZWJ Dha",
288 { 0x09a8, 0x09cd, 0x200d, 0x09a7, 0 },
289 { 0x026f, 0x0163, 0 }
291 { "Ra Halant Ka MatraAU",
292 { 0x09b0, 0x09cd, 0x0995, 0x09cc, 0 },
293 { 0x0179, 0x0151, 0x0276, 0x017e, 0 }
295 { "Ra Halant Ba Halant Ba",
296 { 0x09b0, 0x09cd, 0x09ac, 0x09cd, 0x09ac, 0 },
297 { 0x0232, 0x0276, 0 }
300 { 0x9b0, 0x9cd, 0x995, 0x9be, 0x982, 0 },
301 { 0x151, 0x276, 0x172, 0x143, 0 }
304 { 0x9b0, 0x9cd, 0x995, 0x9be, 0x983, 0 },
305 { 0x151, 0x276, 0x172, 0x144, 0 }
307 /* Test decomposed two part matras */
309 { 0x995, 0x9c7, 0x9be, 0 },
310 { 0x179, 0x151, 0x172, 0 }
313 { 0x995, 0x9c7, 0x9d7, 0 },
314 { 0x179, 0x151, 0x17e, 0 }
317 { 0x9b0, 0x9cd, 0x9ad, 0 },
321 { 0x9f0, 0x9cd, 0x9ad, 0 },
325 { 0x9f1, 0x9cd, 0x9ad, 0 },
326 { 0x191, 0x17d, 0x168, 0 }
332 static const test_set_t tests_bengali2 = {
333 {"MuktiNarrow.ttf", 0},
340 { 0x0995, 0x09cd, 0 },
344 { 0x0995, 0x09cd, 0x0995, 0 },
348 { 0x0995, 0x09bf, 0 },
349 { 0x0095, 0x0073, 0 }
352 { 0x09b0, 0x09cd, 0x0995, 0 },
353 { 0x0073, 0x00e1, 0 }
355 { "Ra Halant Ka MatraI",
356 { 0x09b0, 0x09cd, 0x0995, 0x09bf, 0 },
357 { 0x0095, 0x0073, 0x00e1, 0 }
361 { 0x0095, 0x01c8, 0 }
364 { 0x0995, 0x09bc, 0 },
365 { 0x0073, 0x0093, 0 }
368 { 0x0995, 0x09cd, 0x09b0, 0 },
371 { "Ka Halant Ra Halant Ka",
372 { 0x995, 0x9cd, 0x9b0, 0x9cd, 0x995, 0 },
373 { 0x234, 0x24e, 0x73, 0 }
376 { 0x09af, 0x09cd, 0 },
379 { "Da Halant Ya -> Da Ya-Phala",
380 { 0x09a6, 0x09cd, 0x09af, 0 },
381 { 0x0084, 0x00e2, 0 }
383 { "A Halant Ya -> A Ya-phala",
384 { 0x0985, 0x09cd, 0x09af, 0 },
385 { 0x0067, 0x00e2, 0 }
388 { 0x09a8, 0x09cd, 0x0995, 0 },
391 { "Na Halant ZWNJ Ka",
392 { 0x9a8, 0x9cd, 0x200c, 0x995, 0 },
395 { "Na Halant ZWJ Ka",
396 { 0x9a8, 0x9cd, 0x200d, 0x995, 0 },
399 { "Ka Halant ZWNJ Ka",
400 { 0x9a8, 0x9cd, 0x200d, 0x995, 0 },
403 { "Ka Halant ZWJ Ka",
404 { 0x9a8, 0x9cd, 0x200d, 0x995, 0 },
408 { 0x09a8, 0x09cd, 0x09b0, 0 },
411 { "Na Halant ZWNJ Ra",
412 { 0x09a8, 0x09cd, 0x200c, 0x09b0, 0 },
415 { "Na Halant ZWJ Ra",
416 { 0x9a8, 0x9cd, 0x200d, 0x9b0, 0 },
420 { 0x09a8, 0x09cd, 0x09ac, 0 },
423 { "Na Halant ZWNJ Ba",
424 { 0x9a8, 0x9cd, 0x200c, 0x9ac, 0 },
427 { "Na Halant ZWJ Ba",
428 { 0x9a8, 0x9cd, 0x200d, 0x9ac, 0 },
432 { 0x09a8, 0x09cd, 0x09a7, 0 },
435 { "Na Halant ZWNJ Dha",
436 { 0x09a8, 0x09cd, 0x200c, 0x09a7, 0 },
439 { "Na Halant ZWJ Dha",
440 { 0x09a8, 0x09cd, 0x200d, 0x09a7, 0 },
443 { "Ra Halant Ka MatraAU",
444 { 0x9b0, 0x9cd, 0x995, 0x9cc, 0 },
445 { 0x232, 0x73, 0xe1, 0xa0, 0 }
447 { "Ra Halant Ba Halant Ba",
448 { 0x09b0, 0x09cd, 0x09ac, 0x09cd, 0x09ac, 0 },
449 { 0x013b, 0x00e1, 0 }
455 static const test_set_t tests_bengali3 = {
456 {"LikhanNormal.ttf", 0},
459 { 0x09a8, 0x09cd, 0x09af, 0 },
463 { 0x09b8, 0x09cd, 0x09af, 0 },
467 { 0x09b6, 0x09cd, 0x09af, 0 },
471 { 0x09b7, 0x09cd, 0x09af, 0 },
475 { 0x09b0, 0x09cd, 0x09a8, 0x09cd, 0x200d, 0 },
479 { 0x9b0, 0x9cd, 0x9ad, 0 },
483 { 0x9f0, 0x9cd, 0x9ad, 0 },
487 { 0x9f1, 0x9cd, 0x9ad, 0 },
494 static const test_set_t tests_gurmukhi = {
498 { 0xA15, 0xA4D, 0xa39, 0 },
505 static const test_set_t tests_oriya = {
509 { 0xb15, 0xb4d, 0xb24, 0xb4d, 0xb30, 0 },
513 { 0xb24, 0xb4d, 0xb24, 0xb4d, 0xb2c, 0 },
517 { 0xb28, 0xb4d, 0xb24, 0xb4d, 0xb2c, 0 },
521 { 0xb28, 0xb4d, 0xb24, 0xb4d, 0xb2c, 0 },
525 { 0xb28, 0xb4d, 0xb24, 0xb4d, 0xb30, 0 },
529 { 0xb38, 0xb4d, 0xb24, 0xb4d, 0xb30, 0 },
533 { 0xb28, 0xb4d, 0xb24, 0xb4d, 0xb30, 0xb4d, 0xb2f, 0 },
540 static const test_set_t tests_tamil = {
544 { 0x0b95, 0x0bc2, 0 },
548 { 0x0bae, 0x0bc2, 0 },
552 { 0x0b9a, 0x0bc2, 0 },
556 { 0x0b99, 0x0bc2, 0 },
560 { 0x0bb0, 0x0bc2, 0 },
564 { 0x0ba4, 0x0bc2, 0 },
568 { 0x0b9f, 0x0bc2, 0 },
572 { 0x0b95, 0x0bc6, 0 },
573 { 0x000a, 0x0031, 0 }
576 { 0x0b95, 0x0bca, 0 },
577 { 0x000a, 0x0031, 0x0007, 0 }
580 { 0x0b95, 0x0bc6, 0x0bbe, 0 },
581 { 0x000a, 0x0031, 0x007, 0 }
584 { 0x0b95, 0x0bcd, 0x0bb7, 0 },
588 { 0x0b95, 0x0bcd, 0x0bb7, 0x0bca, 0 },
589 { 0x000a, 0x0049, 0x007, 0 }
592 { 0x0b95, 0x0bcd, 0x0bb7, 0x0bc6, 0x0bbe, 0 },
593 { 0x000a, 0x0049, 0x007, 0 }
596 { 0x0b9f, 0x0bbf, 0 },
600 { 0x0b9f, 0x0bc0, 0 },
604 { 0x0bb2, 0x0bc0, 0 },
608 { 0x0bb2, 0x0bbf, 0 },
612 { 0x0bb0, 0x0bcd, 0 },
616 { 0x0bb0, 0x0bbf, 0 },
620 { 0x0bb0, 0x0bc0, 0 },
628 { 0x0b83, 0x0b95, 0 },
629 { 0x0025, 0x0031, 0 }
635 static const test_set_t tests_telugu = {
636 {"Pothana2000.ttf", 0},
643 { 0xc15, 0xc4d, 0xc37, 0 },
647 { 0xc15, 0xc4d, 0xc37, 0xc4d, 0 },
651 { 0xc15, 0xc4d, 0xc37, 0xc4d, 0xc23, 0 },
655 { 0xc15, 0xc4d, 0xc30, 0 },
659 { 0xc15, 0xc4d, 0xc30, 0xc4d, 0 },
663 { 0xc15, 0xc4d, 0xc30, 0xc4d, 0xc15, 0 },
664 { 0x5a, 0xb2, 0x83, 0 }
667 { 0xc15, 0xc4d, 0xc30, 0xc3f, 0 },
671 { 0xc15, 0xc4d, 0xc15, 0xc48, 0 },
672 { 0xe6, 0xb3, 0x83, 0 }
675 { 0xc15, 0xc4d, 0xc30, 0xc48, 0 },
676 { 0xe6, 0xb3, 0x9f, 0 }
679 { 0xc15, 0xc46, 0xc56, 0 },
686 static const test_set_t tests_kannada1 = {
690 { 0x0ca8, 0x0ccd, 0x0ca8, 0 },
691 { 0x0049, 0x00ba, 0 }
694 { 0x0ca8, 0x0ccd, 0x0ca1, 0 },
695 { 0x0049, 0x00b3, 0 }
698 { 0x0caf, 0x0cc2, 0 },
699 { 0x004f, 0x005d, 0 }
706 { 0x0ce6, 0x0ce7, 0x0ce8, 0 },
707 { 0x006b, 0x006c, 0x006d, 0 }
710 { 0x0cb5, 0x0ccb, 0 },
711 { 0x015f, 0x0067, 0 }
714 { 0x0cb0, 0x0ccd, 0x0cae, 0 },
715 { 0x004e, 0x0082, 0 }
718 { 0x0cb0, 0x0ccd, 0x0c95, 0 },
719 { 0x0036, 0x0082, 0 }
722 { 0x0c95, 0x0ccd, 0x0cb0, 0 },
723 { 0x0036, 0x00c1, 0 }
726 { 0x0cb0, 0x0ccd, 0x200d, 0x0c95, 0 },
727 { 0x0050, 0x00a7, 0 }
733 static const test_set_t tests_kannada2 = {
737 { 0x0cb7, 0x0cc6, 0 },
738 { 0x00b0, 0x006c, 0 }
741 { 0x0cb7, 0x0ccd, 0 },
745 { 0xc95, 0xcbf, 0xcd5, 0 },
749 { 0xc95, 0xcc6, 0xcd5, 0 },
750 { 0x90, 0x6c, 0x73, 0 }
753 { 0xc95, 0xcc6, 0xcd6, 0 },
754 { 0x90, 0x6c, 0x74, 0 }
757 { 0xc95, 0xcc6, 0xcc2, 0 },
758 { 0x90, 0x6c, 0x69, 0 }
761 { 0xc95, 0xcca, 0xcd5, 0 },
762 { 0x90, 0x6c, 0x69, 0x73, 0 }
768 static const test_set_t tests_malayalam1 = {
769 {"AkrutiMal2Normal.ttf", 0},
772 { 0x0d15, 0x0d46, 0 },
773 { 0x005e, 0x0034, 0 }
776 { 0x0d15, 0x0d47, 0 },
777 { 0x005f, 0x0034, 0 }
780 { 0x0d15, 0x0d4b, 0 },
781 { 0x005f, 0x0034, 0x0058, 0 }
784 { 0x0d15, 0x0d48, 0 },
785 { 0x0060, 0x0034, 0 }
788 { 0x0d15, 0x0d4a, 0 },
789 { 0x005e, 0x0034, 0x0058, 0 }
792 { 0x0d30, 0x0d4d, 0x0d15, 0 },
793 { 0x009e, 0x0034, 0 }
796 { 0x0d15, 0x0d4d, 0x0d35, 0 },
797 { 0x0034, 0x007a, 0 }
800 { 0x0d15, 0x0d4d, 0x0d2f, 0 },
801 { 0x0034, 0x00a2, 0 }
804 { 0x0d1f, 0x0d4d, 0x0d1f, 0 },
808 { 0x0d26, 0x0d4d, 0x0d26, 0 },
812 { 0x0d30, 0x0d4d, 0 },
816 { 0x0d30, 0x0d4d, 0x200c, 0 },
820 { 0x0d30, 0x0d4d, 0x200d, 0 },
824 { 0xd15, 0xd46, 0xd3e, 0 },
825 { 0x5e, 0x34, 0x58, 0 }
828 { 0xd15, 0xd47, 0xd3e, 0 },
829 { 0x5f, 0x34, 0x58, 0 }
832 { 0xd15, 0xd46, 0xd57, 0 },
833 { 0x5e, 0x34, 0x65, 0 }
840 { 0xd1f, 0xd4d, 0xd1f, 0xd41, 0xd4d, 0 },
841 { 0x69, 0x5b, 0x64, 0 }
848 static const test_set_t tests_malayalam2 = {
852 { 0xd37, 0xd4d, 0xd1f, 0xd4d, 0xd30, 0xd40, 0 },
856 { 0xd2f, 0xd4d, 0xd15, 0xd4d, 0xd15, 0xd41, 0 },
860 { 0xd33, 0xd4d, 0xd33, 0 },
864 { 0xd2f, 0xd4d, 0xd15, 0xd4d, 0xd15, 0xd41, 0 },
868 { 0xd30, 0xd4d, 0x200d, 0xd35, 0xd4d, 0xd35, 0 },
876 static const test_set_t tests_sinhala = {
877 {"FM-MalithiUW46.ttf", 0},
880 { 0xd9a, 0xdd9, 0xdcf, 0 },
881 { 0x4a, 0x61, 0x42, 0 }
884 { 0xd9a, 0xdd9, 0xddf, 0 },
885 { 0x4a, 0x61, 0x50, 0 }
888 { 0xd9a, 0xdd9, 0xdca, 0 },
892 { 0xd9a, 0xddc, 0xdca, 0 },
893 { 0x4a, 0x61, 0x42, 0x41, 0 }
901 { 0x4a, 0x61, 0x42, 0x41, 0 }
907 static const test_set_t tests_khmer = {
911 { 0x179a, 0x17cd, 0 },
915 { 0x179f, 0x17c5, 0 },
919 { 0x1790, 0x17d2, 0x1784, 0x17c3, 0 },
920 { 0x275, 0x242, 0x182, 0 }
927 { 0x1781, 0x17d2, 0x1798, 0x17c2, 0 },
928 { 0x274, 0x233, 0x197, 0 }
931 { 0x1798, 0x17b6, 0 },
935 { 0x179a, 0x17b8, 0 },
939 { 0x1787, 0x17b6, 0 },
943 { 0x1798, 0x17d2, 0x1796, 0x17bb, 0 },
944 { 0x24a, 0x195, 0x26d, 0 }
950 static const test_set_t tests_nko = {
951 {"DejaVuSans.ttf", 0},
959 { 0x14d9, 0x14db, 0 }
962 { 0x7ca, 0x7fa, 0x7ca, 0 },
963 { 0x14d9, 0x5ec, 0x14db, 0 }
966 { 0x7ca, 0x7f3, 0x7ca, 0 },
967 { 0x14d9, 0x5e7, 0x14db, 0 }
970 { 0x7ca, 0x7f3, 0x7fa, 0x7ca, 0 },
971 { 0x14d9, 0x5ec, 0x5e7, 0x14db, 0 }
977 static const test_set_t tests_linearb = {
981 { 0xd800, 0xdc01, 0xd800, 0xdc02, 0xd800, 0xdc03, 0 },
982 { 0x5, 0x6, 0x7, 0 },
993 FT_Library ft_library;
999 ft_fixture_init (ft_fixture_t *f, gconstpointer user_data)
1001 const test_t *test = user_data;
1002 char *font_file = get_font_file (test->font_data);
1005 FT_Init_FreeType (&f->ft_library);
1007 err = FT_New_Face (f->ft_library, font_file, test->font_data->face_index, &f->ft_face);
1008 g_assert_cmpint (err, ==, 0);
1010 f->font = hb_ft_font_create (f->ft_face, NULL);
1016 ft_fixture_finish (ft_fixture_t *f, gconstpointer user_data)
1018 hb_font_destroy (f->font);
1020 FT_Done_Face (f->ft_face);
1021 FT_Done_FreeType (f->ft_library);
1025 test_shape_complex (ft_fixture_t *f, gconstpointer user_data)
1027 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;
1037 if (data->comments[0])
1038 g_test_message ("Test comments: %s", data->comments);
1040 buffer = hb_buffer_create (0);
1041 for (len = 0; data->characters[len]; len++) ;
1042 hb_buffer_add_utf32 (buffer, data->characters, len, 0, len);
1044 hb_shape (f->font, buffer, NULL, 0);
1046 for (len = 0; data->glyphs[len]; len++) ;
1049 glyphs = hb_buffer_get_glyph_infos (buffer, &len);
1050 fail = len != expected_len;
1052 for (i = 0; i < len; i++)
1053 if (glyphs[i].codepoint != data->glyphs[i]) {
1058 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);
1069 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... */
1074 g_test_message ("PASS");
1076 hb_buffer_destroy (buffer);
1080 test_shape_complex_skipped (gconstpointer user_data)
1082 const test_t *test = user_data;
1083 const test_data_t *data = test->test_data;
1085 if (data->comments[0])
1086 g_test_message ("Test comments: %s", data->comments);
1088 g_test_message ("Skipping test");
1093 add_test_set (const test_set_t *test_set, const char *set_name)
1095 const test_data_t *data;
1099 font_file = get_font_file (&test_set->font_data);
1100 skip = !g_file_test (font_file, G_FILE_TEST_EXISTS);
1103 for (data = test_set->test_datas; data->characters[0]; data++) {
1106 const hb_codepoint_t *p;
1108 test_t *test = g_slice_new0 (test_t);
1109 test->font_data = &test_set->font_data;
1110 test->test_data = data;
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] = '>';
1117 flavor = g_strdup_printf ("%s/%s/%ld:%s", set_name, test_set->font_data.font_file, data - test_set->test_datas, str->str);
1119 g_string_free (str, TRUE);
1122 hb_test_add_data_flavor ((const void *) test, flavor, test_shape_complex_skipped);
1124 hb_test_add_fixture_flavor (ft_fixture, (const void *) test, flavor, test_shape_complex);
1132 main (int argc, char **argv)
1134 hb_test_init (&argc, &argv);
1136 #define TEST_SET(name) add_test_set (&tests_##name, #name)
1138 TEST_SET (devanagari1);
1139 TEST_SET (devanagari2);
1140 TEST_SET (bengali1);
1141 TEST_SET (bengali2);
1142 TEST_SET (bengali3);
1143 TEST_SET (gurmukhi);
1147 TEST_SET (kannada1);
1148 TEST_SET (kannada2);
1149 TEST_SET (malayalam1);
1150 TEST_SET (malayalam2);
1158 return hb_test_run();