blob: 75741fb3b017b6762592023f4ec7c70c046882be [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 Esfahboda346e922011-06-28 12:49:18 -040074static const test_set_t tests_greek = {
Behdad Esfahbod9704f0c2011-06-28 16:15:46 -040075 {"DejaVuSans.ttf", 0},
Behdad Esfahboda346e922011-06-28 12:49:18 -040076 {
77 { "",
78 { 0x3b1, 0x300, 0x313, 0 },
79 { 0xb8, 0x3d3, 0x3c7, 0 }
80 },
81 { "",
82 { 0x3b1, 0x313, 0x300, 0 },
83 { 0xd4, 0 }
84 },
85 {{0}}
86 }
87};
88
Behdad Esfahbod42d453b2011-06-28 16:59:16 -040089static const test_set_t tests_devanagari1 = {
Behdad Esfahbod9704f0c2011-06-28 16:15:46 -040090 {"raghu.ttf", 0},
Behdad Esfahboda346e922011-06-28 12:49:18 -040091 {
92 { "Ka",
93 { 0x0915, 0 },
94 { 0x0080, 0 }
95 },
96 { "Ka Halant",
97 { 0x0915, 0x094d, 0 },
98 { 0x0080, 0x0051, 0 }
99 },
100 { "Ka Halant Ka",
101 { 0x0915, 0x094d, 0x0915, 0 },
102 { 0x00c8, 0x0080, 0 }
103 },
104 { "Ka MatraI",
105 { 0x0915, 0x093f, 0 },
106 { 0x01d1, 0x0080, 0 }
107 },
108 { "Ra Halant Ka",
109 { 0x0930, 0x094d, 0x0915, 0 },
110 { 0x0080, 0x005b, 0 }
111 },
112 { "Ra Halant Ka MatraI",
113 { 0x0930, 0x094d, 0x0915, 0x093f, 0 },
114 { 0x01d1, 0x0080, 0x005b, 0 }
115 },
116 { "MatraI",
117 { 0x093f, 0 },
118 { 0x01d4, 0x029c, 0 }
119 },
120 { "Ka Nukta",
121 { 0x0915, 0x093c, 0 },
122 { 0x00a4, 0 }
123 },
124 { "Ka Halant Ra",
125 { 0x0915, 0x094d, 0x0930, 0 },
126 { 0x0110, 0 }
127 },
128 { "Ka Halant Ra Halant Ka",
129 { 0x0915, 0x094d, 0x0930, 0x094d, 0x0915, 0 },
130 { 0x0158, 0x0080, 0 }
131 },
132 { "",
133 { 0x0930, 0x094d, 0x200d, 0 },
134 { 0x00e2, 0 }
135 },
136 { "",
137 { 0x0915, 0x094d, 0x0930, 0x094d, 0x200d, 0 },
138 { 0x0158, 0 }
139 },
140 {{0}}
141 }
142};
143
Behdad Esfahbod42d453b2011-06-28 16:59:16 -0400144static const test_set_t tests_devanagari2 = {
Behdad Esfahbod9704f0c2011-06-28 16:15:46 -0400145 {"mangal.ttf", 0},
Behdad Esfahboda346e922011-06-28 12:49:18 -0400146 {
147 { "Ka",
148 { 0x0915, 0 },
149 { 0x0080, 0 }
150 },
151 { "Ka Halant",
152 { 0x0915, 0x094d, 0 },
153 { 0x0080, 0x0051, 0 }
154 },
155 { "Ka Halant Ka",
156 { 0x0915, 0x094d, 0x0915, 0 },
157 { 0x00c8, 0x0080, 0 }
158 },
159 { "Ka MatraI",
160 { 0x0915, 0x093f, 0 },
161 { 0x01d1, 0x0080, 0 }
162 },
163 { "Ra Halant Ka",
164 { 0x0930, 0x094d, 0x0915, 0 },
165 { 0x0080, 0x005b, 0 }
166 },
167 { "Ra Halant Ka MatraI",
168 { 0x0930, 0x094d, 0x0915, 0x093f, 0 },
169 { 0x01d1, 0x0080, 0x005b, 0 }
170 },
171 { "MatraI",
172 { 0x093f, 0 },
173 { 0x01d4, 0x029c, 0 }
174 },
175 { "Ka Nukta",
176 { 0x0915, 0x093c, 0 },
177 { 0x00a4, 0 }
178 },
179 { "Ka Halant Ra",
180 { 0x0915, 0x094d, 0x0930, 0 },
181 { 0x0110, 0 }
182 },
183 { "Ka Halant Ra Halant Ka",
184 { 0x0915, 0x094d, 0x0930, 0x094d, 0x0915, 0 },
185 { 0x0158, 0x0080, 0 }
186 },
187 { "",
188 { 0x92b, 0x94d, 0x930, 0 },
189 { 0x125, 0 }
190 },
191 { "",
192 { 0x92b, 0x93c, 0x94d, 0x930, 0 },
193 { 0x149, 0 }
194 },
195 {{0}}
196 }
197};
198
Behdad Esfahbod42d453b2011-06-28 16:59:16 -0400199static const test_set_t tests_bengali1 = {
Behdad Esfahbod9704f0c2011-06-28 16:15:46 -0400200 {"AkaashNormal.ttf", 0},
Behdad Esfahboda346e922011-06-28 12:49:18 -0400201 {
202 { "Ka",
203 { 0x0995, 0 },
204 { 0x0151, 0 }
205 },
206 { "Ka Halant",
207 { 0x0995, 0x09cd, 0 },
208 { 0x0151, 0x017d, 0 }
209 },
210 { "Ka Halant Ka",
211 { 0x0995, 0x09cd, 0x0995, 0 },
212 { 0x019b, 0 }
213 },
214 { "Ka MatraI",
215 { 0x0995, 0x09bf, 0 },
216 { 0x0173, 0x0151, 0 }
217 },
218 { "Ra Halant Ka",
219 { 0x09b0, 0x09cd, 0x0995, 0 },
220 { 0x0151, 0x0276, 0 }
221 },
222 { "Ra Halant Ka MatraI",
223 { 0x09b0, 0x09cd, 0x0995, 0x09bf, 0 },
224 { 0x0173, 0x0151, 0x0276, 0 }
225 },
226 { "Ka Nukta",
227 { 0x0995, 0x09bc, 0 },
228 { 0x0151, 0x0171, 0 }
229 },
230 { "Ka Halant Ra",
231 { 0x0995, 0x09cd, 0x09b0, 0 },
232 { 0x01f4, 0 }
233 },
234 { "Ka Halant Ra Halant Ka",
235 { 0x0995, 0x09cd, 0x09b0, 0x09cd, 0x0995, 0 },
236 { 0x025c, 0x0276, 0x0151, 0 }
237 },
238 { "Ya + Halant",
239 { 0x09af, 0x09cd, 0 },
240 { 0x016a, 0x017d, 0 }
241 },
242 { "Da Halant Ya -> Da Ya-Phala",
243 { 0x09a6, 0x09cd, 0x09af, 0 },
244 { 0x01e5, 0 }
245 },
246 { "A Halant Ya -> A Ya-phala",
247 { 0x0985, 0x09cd, 0x09af, 0 },
248 { 0x0145, 0x01cf, 0 }
249 },
250 { "Na Halant Ka",
251 { 0x09a8, 0x09cd, 0x0995, 0 },
252 { 0x026f, 0x0151, 0 }
253 },
254 { "Na Halant ZWNJ Ka",
255 { 0x09a8, 0x09cd, 0x200c, 0x0995, 0 },
256 { 0x0164, 0x017d, 0x0151, 0 }
257 },
258 { "Na Halant ZWJ Ka",
259 { 0x09a8, 0x09cd, 0x200d, 0x0995, 0 },
260 { 0x026f, 0x0151, 0 }
261 },
262 { "Ka Halant ZWNJ Ka",
263 { 0x0995, 0x09cd, 0x200c, 0x0995, 0 },
264 { 0x0151, 0x017d, 0x0151, 0 }
265 },
266 { "Ka Halant ZWJ Ka",
267 { 0x0995, 0x09cd, 0x200d, 0x0995, 0 },
268 { 0x025c, 0x0151, 0 }
269 },
270 { "Na Halant Ra",
271 { 0x09a8, 0x09cd, 0x09b0, 0 },
272 { 0x0207, 0 }
273 },
274 { "Na Halant ZWNJ Ra",
275 { 0x09a8, 0x09cd, 0x200c, 0x09b0, 0 },
276 { 0x0164, 0x017d, 0x016b, 0 }
277 },
278 { "Na Halant ZWJ Ra",
279 { 0x09a8, 0x09cd, 0x200d, 0x09b0, 0 },
280 { 0x026f, 0x016b, 0 }
281 },
282 { "Na Halant Ba",
283 { 0x09a8, 0x09cd, 0x09ac, 0 },
284 { 0x022f, 0 }
285 },
286 { "Na Halant ZWNJ Ba",
287 { 0x09a8, 0x09cd, 0x200c, 0x09ac, 0 },
288 { 0x0164, 0x017d, 0x0167, 0 }
289 },
290 { "Na Halant ZWJ Ba",
291 { 0x09a8, 0x09cd, 0x200d, 0x09ac, 0 },
292 { 0x026f, 0x0167, 0 }
293 },
294 { "Na Halant Dha",
295 { 0x09a8, 0x09cd, 0x09a7, 0 },
296 { 0x01d3, 0 }
297 },
298 { "Na Halant ZWNJ Dha",
299 { 0x09a8, 0x09cd, 0x200c, 0x09a7, 0 },
300 { 0x0164, 0x017d, 0x0163, 0 }
301 },
302 { "Na Halant ZWJ Dha",
303 { 0x09a8, 0x09cd, 0x200d, 0x09a7, 0 },
304 { 0x026f, 0x0163, 0 }
305 },
306 { "Ra Halant Ka MatraAU",
307 { 0x09b0, 0x09cd, 0x0995, 0x09cc, 0 },
308 { 0x0179, 0x0151, 0x0276, 0x017e, 0 }
309 },
310 { "Ra Halant Ba Halant Ba",
311 { 0x09b0, 0x09cd, 0x09ac, 0x09cd, 0x09ac, 0 },
312 { 0x0232, 0x0276, 0 }
313 },
314 { "",
315 { 0x9b0, 0x9cd, 0x995, 0x9be, 0x982, 0 },
316 { 0x151, 0x276, 0x172, 0x143, 0 }
317 },
318 { "",
319 { 0x9b0, 0x9cd, 0x995, 0x9be, 0x983, 0 },
320 { 0x151, 0x276, 0x172, 0x144, 0 }
321 },
322 /* Test decomposed two part matras */
323 { "",
324 { 0x995, 0x9c7, 0x9be, 0 },
325 { 0x179, 0x151, 0x172, 0 }
326 },
327 { "",
328 { 0x995, 0x9c7, 0x9d7, 0 },
329 { 0x179, 0x151, 0x17e, 0 }
330 },
331 { "",
332 { 0x9b0, 0x9cd, 0x9ad, 0 },
333 { 0x168, 0x276, 0 }
334 },
335 { "",
336 { 0x9f0, 0x9cd, 0x9ad, 0 },
337 { 0x168, 0x276, 0 }
338 },
339 { "",
340 { 0x9f1, 0x9cd, 0x9ad, 0 },
341 { 0x191, 0x17d, 0x168, 0 }
342 },
343 {{0}}
344 }
345};
346
Behdad Esfahbod42d453b2011-06-28 16:59:16 -0400347static const test_set_t tests_bengali2 = {
Behdad Esfahbod9704f0c2011-06-28 16:15:46 -0400348 {"MuktiNarrow.ttf", 0},
Behdad Esfahboda346e922011-06-28 12:49:18 -0400349 {
350 { "Ka",
351 { 0x0995, 0 },
352 { 0x0073, 0 }
353 },
354 { "Ka Halant",
355 { 0x0995, 0x09cd, 0 },
356 { 0x00b9, 0 }
357 },
358 { "Ka Halant Ka",
359 { 0x0995, 0x09cd, 0x0995, 0 },
360 { 0x0109, 0 }
361 },
362 { "Ka MatraI",
363 { 0x0995, 0x09bf, 0 },
364 { 0x0095, 0x0073, 0 }
365 },
366 { "Ra Halant Ka",
367 { 0x09b0, 0x09cd, 0x0995, 0 },
368 { 0x0073, 0x00e1, 0 }
369 },
370 { "Ra Halant Ka MatraI",
371 { 0x09b0, 0x09cd, 0x0995, 0x09bf, 0 },
372 { 0x0095, 0x0073, 0x00e1, 0 }
373 },
374 { "MatraI",
375 { 0x09bf, 0 },
376 { 0x0095, 0x01c8, 0 }
377 },
378 { "Ka Nukta",
379 { 0x0995, 0x09bc, 0 },
380 { 0x0073, 0x0093, 0 }
381 },
382 { "Ka Halant Ra",
383 { 0x0995, 0x09cd, 0x09b0, 0 },
384 { 0x00e5, 0 }
385 },
386 { "Ka Halant Ra Halant Ka",
387 { 0x995, 0x9cd, 0x9b0, 0x9cd, 0x995, 0 },
388 { 0x234, 0x24e, 0x73, 0 }
389 },
390 { "Ya + Halant",
391 { 0x09af, 0x09cd, 0 },
392 { 0x00d2, 0 }
393 },
394 { "Da Halant Ya -> Da Ya-Phala",
395 { 0x09a6, 0x09cd, 0x09af, 0 },
396 { 0x0084, 0x00e2, 0 }
397 },
398 { "A Halant Ya -> A Ya-phala",
399 { 0x0985, 0x09cd, 0x09af, 0 },
400 { 0x0067, 0x00e2, 0 }
401 },
402 { "Na Halant Ka",
403 { 0x09a8, 0x09cd, 0x0995, 0 },
404 { 0x0188, 0 }
405 },
406 { "Na Halant ZWNJ Ka",
407 { 0x9a8, 0x9cd, 0x200c, 0x995, 0 },
408 { 0xcc, 0x73, 0 }
409 },
410 { "Na Halant ZWJ Ka",
411 { 0x9a8, 0x9cd, 0x200d, 0x995, 0 },
412 { 0x247, 0x73, 0 }
413 },
414 { "Ka Halant ZWNJ Ka",
415 { 0x9a8, 0x9cd, 0x200d, 0x995, 0 },
416 { 0x247, 0x73, 0 }
417 },
418 { "Ka Halant ZWJ Ka",
419 { 0x9a8, 0x9cd, 0x200d, 0x995, 0 },
420 { 0x247, 0x73, 0 }
421 },
422 { "Na Halant Ra",
423 { 0x09a8, 0x09cd, 0x09b0, 0 },
424 { 0x00f8, 0 }
425 },
426 { "Na Halant ZWNJ Ra",
427 { 0x09a8, 0x09cd, 0x200c, 0x09b0, 0 },
428 { 0xcc, 0x8d, 0 }
429 },
430 { "Na Halant ZWJ Ra",
431 { 0x9a8, 0x9cd, 0x200d, 0x9b0, 0 },
432 { 0x247, 0x8d, 0 }
433 },
434 { "Na Halant Ba",
435 { 0x09a8, 0x09cd, 0x09ac, 0 },
436 { 0x0139, 0 }
437 },
438 { "Na Halant ZWNJ Ba",
439 { 0x9a8, 0x9cd, 0x200c, 0x9ac, 0 },
440 { 0xcc, 0x89, 0 }
441 },
442 { "Na Halant ZWJ Ba",
443 { 0x9a8, 0x9cd, 0x200d, 0x9ac, 0 },
444 { 0x247, 0x89, 0 }
445 },
446 { "Na Halant Dha",
447 { 0x09a8, 0x09cd, 0x09a7, 0 },
448 { 0x0145, 0 }
449 },
450 { "Na Halant ZWNJ Dha",
451 { 0x09a8, 0x09cd, 0x200c, 0x09a7, 0 },
452 { 0xcc, 0x85, 0 }
453 },
454 { "Na Halant ZWJ Dha",
455 { 0x09a8, 0x09cd, 0x200d, 0x09a7, 0 },
456 { 0x247, 0x85, 0 }
457 },
458 { "Ra Halant Ka MatraAU",
459 { 0x9b0, 0x9cd, 0x995, 0x9cc, 0 },
460 { 0x232, 0x73, 0xe1, 0xa0, 0 }
461 },
462 { "Ra Halant Ba Halant Ba",
463 { 0x09b0, 0x09cd, 0x09ac, 0x09cd, 0x09ac, 0 },
464 { 0x013b, 0x00e1, 0 }
465 },
466 {{0}}
467 }
468};
469
Behdad Esfahbod42d453b2011-06-28 16:59:16 -0400470static const test_set_t tests_bengali3 = {
Behdad Esfahbod9704f0c2011-06-28 16:15:46 -0400471 {"LikhanNormal.ttf", 0},
Behdad Esfahboda346e922011-06-28 12:49:18 -0400472 {
473 { "",
474 { 0x09a8, 0x09cd, 0x09af, 0 },
475 { 0x01ca, 0 }
476 },
477 { "",
478 { 0x09b8, 0x09cd, 0x09af, 0 },
479 { 0x020e, 0 }
480 },
481 { "",
482 { 0x09b6, 0x09cd, 0x09af, 0 },
483 { 0x01f4, 0 }
484 },
485 { "",
486 { 0x09b7, 0x09cd, 0x09af, 0 },
487 { 0x01fe, 0 }
488 },
489 { "",
490 { 0x09b0, 0x09cd, 0x09a8, 0x09cd, 0x200d, 0 },
491 { 0x10b, 0x167, 0 }
492 },
493 { "",
494 { 0x9b0, 0x9cd, 0x9ad, 0 },
495 { 0xa1, 0x167, 0 }
496 },
497 { "",
498 { 0x9f0, 0x9cd, 0x9ad, 0 },
499 { 0xa1, 0x167, 0 }
500 },
501 { "",
502 { 0x9f1, 0x9cd, 0x9ad, 0 },
503 { 0x11c, 0xa1, 0 }
504 },
505 {{0}}
506 }
507};
508
509static const test_set_t tests_gurmukhi = {
Behdad Esfahbod9704f0c2011-06-28 16:15:46 -0400510 {"lohit_pa.ttf", 0},
Behdad Esfahboda346e922011-06-28 12:49:18 -0400511 {
512 { "",
513 { 0xA15, 0xA4D, 0xa39, 0 },
514 { 0x3b, 0x8b, 0 }
515 },
516 {{0}}
517 }
518};
519
520static const test_set_t tests_oriya = {
Behdad Esfahbod9704f0c2011-06-28 16:15:46 -0400521 {"utkalm.ttf", 0},
Behdad Esfahboda346e922011-06-28 12:49:18 -0400522 {
523 { "",
524 { 0xb15, 0xb4d, 0xb24, 0xb4d, 0xb30, 0 },
525 { 0x150, 0x125, 0 }
526 },
527 { "",
528 { 0xb24, 0xb4d, 0xb24, 0xb4d, 0xb2c, 0 },
529 { 0x151, 0x120, 0 }
530 },
531 { "",
532 { 0xb28, 0xb4d, 0xb24, 0xb4d, 0xb2c, 0 },
533 { 0x152, 0x120, 0 }
534 },
535 { "",
536 { 0xb28, 0xb4d, 0xb24, 0xb4d, 0xb2c, 0 },
537 { 0x152, 0x120, 0 }
538 },
539 { "",
540 { 0xb28, 0xb4d, 0xb24, 0xb4d, 0xb30, 0 },
541 { 0x176, 0 }
542 },
543 { "",
544 { 0xb38, 0xb4d, 0xb24, 0xb4d, 0xb30, 0 },
545 { 0x177, 0 }
546 },
547 { "",
548 { 0xb28, 0xb4d, 0xb24, 0xb4d, 0xb30, 0xb4d, 0xb2f, 0 },
549 { 0x176, 0x124, 0 }
550 },
551 {{0}}
552 }
553};
554
555static const test_set_t tests_tamil = {
Behdad Esfahbod9704f0c2011-06-28 16:15:46 -0400556 {"akruti1.ttf", 0},
Behdad Esfahboda346e922011-06-28 12:49:18 -0400557 {
558 { "",
559 { 0x0b95, 0x0bc2, 0 },
560 { 0x004e, 0 }
561 },
562 { "",
563 { 0x0bae, 0x0bc2, 0 },
564 { 0x009e, 0 }
565 },
566 { "",
567 { 0x0b9a, 0x0bc2, 0 },
568 { 0x0058, 0 }
569 },
570 { "",
571 { 0x0b99, 0x0bc2, 0 },
572 { 0x0053, 0 }
573 },
574 { "",
575 { 0x0bb0, 0x0bc2, 0 },
576 { 0x00a8, 0 }
577 },
578 { "",
579 { 0x0ba4, 0x0bc2, 0 },
580 { 0x008e, 0 }
581 },
582 { "",
583 { 0x0b9f, 0x0bc2, 0 },
584 { 0x0062, 0 }
585 },
586 { "",
587 { 0x0b95, 0x0bc6, 0 },
588 { 0x000a, 0x0031, 0 }
589 },
590 { "",
591 { 0x0b95, 0x0bca, 0 },
592 { 0x000a, 0x0031, 0x0007, 0 }
593 },
594 { "",
595 { 0x0b95, 0x0bc6, 0x0bbe, 0 },
596 { 0x000a, 0x0031, 0x007, 0 }
597 },
598 { "",
599 { 0x0b95, 0x0bcd, 0x0bb7, 0 },
600 { 0x0049, 0 }
601 },
602 { "",
603 { 0x0b95, 0x0bcd, 0x0bb7, 0x0bca, 0 },
604 { 0x000a, 0x0049, 0x007, 0 }
605 },
606 { "",
607 { 0x0b95, 0x0bcd, 0x0bb7, 0x0bc6, 0x0bbe, 0 },
608 { 0x000a, 0x0049, 0x007, 0 }
609 },
610 { "",
611 { 0x0b9f, 0x0bbf, 0 },
612 { 0x005f, 0 }
613 },
614 { "",
615 { 0x0b9f, 0x0bc0, 0 },
616 { 0x0060, 0 }
617 },
618 { "",
619 { 0x0bb2, 0x0bc0, 0 },
620 { 0x00ab, 0 }
621 },
622 { "",
623 { 0x0bb2, 0x0bbf, 0 },
624 { 0x00aa, 0 }
625 },
626 { "",
627 { 0x0bb0, 0x0bcd, 0 },
628 { 0x00a4, 0 }
629 },
630 { "",
631 { 0x0bb0, 0x0bbf, 0 },
632 { 0x00a5, 0 }
633 },
634 { "",
635 { 0x0bb0, 0x0bc0, 0 },
636 { 0x00a6, 0 }
637 },
638 { "",
639 { 0x0b83, 0 },
640 { 0x0025, 0 }
641 },
642 { "",
643 { 0x0b83, 0x0b95, 0 },
644 { 0x0025, 0x0031, 0 }
645 },
646 {{0}}
647 }
648};
649
650static const test_set_t tests_telugu = {
Behdad Esfahbod9704f0c2011-06-28 16:15:46 -0400651 {"Pothana2000.ttf", 0},
Behdad Esfahboda346e922011-06-28 12:49:18 -0400652 {
653 { "",
654 { 0xc15, 0xc4d, 0 },
655 { 0xbb, 0 }
656 },
657 { "",
658 { 0xc15, 0xc4d, 0xc37, 0 },
659 { 0x4b, 0 }
660 },
661 { "",
662 { 0xc15, 0xc4d, 0xc37, 0xc4d, 0 },
663 { 0xe0, 0 }
664 },
665 { "",
666 { 0xc15, 0xc4d, 0xc37, 0xc4d, 0xc23, 0 },
667 { 0x4b, 0x91, 0 }
668 },
669 { "",
670 { 0xc15, 0xc4d, 0xc30, 0 },
671 { 0x5a, 0xb2, 0 }
672 },
673 { "",
674 { 0xc15, 0xc4d, 0xc30, 0xc4d, 0 },
675 { 0xbb, 0xb2, 0 }
676 },
677 { "",
678 { 0xc15, 0xc4d, 0xc30, 0xc4d, 0xc15, 0 },
679 { 0x5a, 0xb2, 0x83, 0 }
680 },
681 { "",
682 { 0xc15, 0xc4d, 0xc30, 0xc3f, 0 },
683 { 0xe2, 0xb2, 0 }
684 },
685 { "",
686 { 0xc15, 0xc4d, 0xc15, 0xc48, 0 },
687 { 0xe6, 0xb3, 0x83, 0 }
688 },
689 { "",
690 { 0xc15, 0xc4d, 0xc30, 0xc48, 0 },
691 { 0xe6, 0xb3, 0x9f, 0 }
692 },
693 { "",
694 { 0xc15, 0xc46, 0xc56, 0 },
695 { 0xe6, 0xb3, 0 }
696 },
697 {{0}}
698 }
699};
700
Behdad Esfahbod42d453b2011-06-28 16:59:16 -0400701static const test_set_t tests_kannada1 = {
Behdad Esfahbod9704f0c2011-06-28 16:15:46 -0400702 {"Sampige.ttf", 0},
Behdad Esfahboda346e922011-06-28 12:49:18 -0400703 {
704 { "",
705 { 0x0ca8, 0x0ccd, 0x0ca8, 0 },
706 { 0x0049, 0x00ba, 0 }
707 },
708 { "",
709 { 0x0ca8, 0x0ccd, 0x0ca1, 0 },
710 { 0x0049, 0x00b3, 0 }
711 },
712 { "",
713 { 0x0caf, 0x0cc2, 0 },
714 { 0x004f, 0x005d, 0 }
715 },
716 { "",
717 { 0x0ce0, 0 },
718 { 0x006a, 0 }
719 },
720 { "",
721 { 0x0ce6, 0x0ce7, 0x0ce8, 0 },
722 { 0x006b, 0x006c, 0x006d, 0 }
723 },
724 { "",
725 { 0x0cb5, 0x0ccb, 0 },
726 { 0x015f, 0x0067, 0 }
727 },
728 { "",
729 { 0x0cb0, 0x0ccd, 0x0cae, 0 },
730 { 0x004e, 0x0082, 0 }
731 },
732 { "",
733 { 0x0cb0, 0x0ccd, 0x0c95, 0 },
734 { 0x0036, 0x0082, 0 }
735 },
736 { "",
737 { 0x0c95, 0x0ccd, 0x0cb0, 0 },
738 { 0x0036, 0x00c1, 0 }
739 },
740 { "",
741 { 0x0cb0, 0x0ccd, 0x200d, 0x0c95, 0 },
742 { 0x0050, 0x00a7, 0 }
743 },
744 {{0}}
745 }
746};
747
Behdad Esfahbod42d453b2011-06-28 16:59:16 -0400748static const test_set_t tests_kannada2 = {
Behdad Esfahbod9704f0c2011-06-28 16:15:46 -0400749 {"tunga.ttf", 0},
Behdad Esfahboda346e922011-06-28 12:49:18 -0400750 {
751 { "",
752 { 0x0cb7, 0x0cc6, 0 },
753 { 0x00b0, 0x006c, 0 }
754 },
755 { "",
756 { 0x0cb7, 0x0ccd, 0 },
757 { 0x0163, 0 }
758 },
759 { "",
760 { 0xc95, 0xcbf, 0xcd5, 0 },
761 { 0x114, 0x73, 0 }
762 },
763 { "",
764 { 0xc95, 0xcc6, 0xcd5, 0 },
765 { 0x90, 0x6c, 0x73, 0 }
766 },
767 { "",
768 { 0xc95, 0xcc6, 0xcd6, 0 },
769 { 0x90, 0x6c, 0x74, 0 }
770 },
771 { "",
772 { 0xc95, 0xcc6, 0xcc2, 0 },
773 { 0x90, 0x6c, 0x69, 0 }
774 },
775 { "",
776 { 0xc95, 0xcca, 0xcd5, 0 },
777 { 0x90, 0x6c, 0x69, 0x73, 0 }
778 },
779 {{0}}
780 }
781};
782
Behdad Esfahbod42d453b2011-06-28 16:59:16 -0400783static const test_set_t tests_malayalam1 = {
Behdad Esfahbod9704f0c2011-06-28 16:15:46 -0400784 {"AkrutiMal2Normal.ttf", 0},
Behdad Esfahboda346e922011-06-28 12:49:18 -0400785 {
786 { "",
787 { 0x0d15, 0x0d46, 0 },
788 { 0x005e, 0x0034, 0 }
789 },
790 { "",
791 { 0x0d15, 0x0d47, 0 },
792 { 0x005f, 0x0034, 0 }
793 },
794 { "",
795 { 0x0d15, 0x0d4b, 0 },
796 { 0x005f, 0x0034, 0x0058, 0 }
797 },
798 { "",
799 { 0x0d15, 0x0d48, 0 },
800 { 0x0060, 0x0034, 0 }
801 },
802 { "",
803 { 0x0d15, 0x0d4a, 0 },
804 { 0x005e, 0x0034, 0x0058, 0 }
805 },
806 { "",
807 { 0x0d30, 0x0d4d, 0x0d15, 0 },
808 { 0x009e, 0x0034, 0 }
809 },
810 { "",
811 { 0x0d15, 0x0d4d, 0x0d35, 0 },
812 { 0x0034, 0x007a, 0 }
813 },
814 { "",
815 { 0x0d15, 0x0d4d, 0x0d2f, 0 },
816 { 0x0034, 0x00a2, 0 }
817 },
818 { "",
819 { 0x0d1f, 0x0d4d, 0x0d1f, 0 },
820 { 0x0069, 0 }
821 },
822 { "",
823 { 0x0d26, 0x0d4d, 0x0d26, 0 },
824 { 0x0074, 0 }
825 },
826 { "",
827 { 0x0d30, 0x0d4d, 0 },
828 { 0x009e, 0 }
829 },
830 { "",
831 { 0x0d30, 0x0d4d, 0x200c, 0 },
832 { 0x009e, 0 }
833 },
834 { "",
835 { 0x0d30, 0x0d4d, 0x200d, 0 },
836 { 0x009e, 0 }
837 },
838 { "",
839 { 0xd15, 0xd46, 0xd3e, 0 },
840 { 0x5e, 0x34, 0x58, 0 }
841 },
842 { "",
843 { 0xd15, 0xd47, 0xd3e, 0 },
844 { 0x5f, 0x34, 0x58, 0 }
845 },
846 { "",
847 { 0xd15, 0xd46, 0xd57, 0 },
848 { 0x5e, 0x34, 0x65, 0 }
849 },
850 { "",
851 { 0xd15, 0xd57, 0 },
852 { 0x34, 0x65, 0 }
853 },
854 { "",
855 { 0xd1f, 0xd4d, 0xd1f, 0xd41, 0xd4d, 0 },
856 { 0x69, 0x5b, 0x64, 0 }
857 },
858
859 {{0}}
860 }
861};
862
Behdad Esfahbod42d453b2011-06-28 16:59:16 -0400863static const test_set_t tests_malayalam2 = {
Behdad Esfahbod9704f0c2011-06-28 16:15:46 -0400864 {"Rachana.ttf", 0},
Behdad Esfahboda346e922011-06-28 12:49:18 -0400865 {
866 { "",
867 { 0xd37, 0xd4d, 0xd1f, 0xd4d, 0xd30, 0xd40, 0 },
868 { 0x385, 0xa3, 0 }
869 },
870 { "",
871 { 0xd2f, 0xd4d, 0xd15, 0xd4d, 0xd15, 0xd41, 0 },
872 { 0x2ff, 0 }
873 },
874 { "",
875 { 0xd33, 0xd4d, 0xd33, 0 },
876 { 0x3f8, 0 }
877 },
878 { "",
879 { 0xd2f, 0xd4d, 0xd15, 0xd4d, 0xd15, 0xd41, 0 },
880 { 0x2ff, 0 }
881 },
882 { "",
883 { 0xd30, 0xd4d, 0x200d, 0xd35, 0xd4d, 0xd35, 0 },
884 { 0xf3, 0x350, 0 }
885 },
886
887 {{0}}
888 }
889};
890
891static const test_set_t tests_sinhala = {
Behdad Esfahbod9704f0c2011-06-28 16:15:46 -0400892 {"FM-MalithiUW46.ttf", 0},
Behdad Esfahboda346e922011-06-28 12:49:18 -0400893 {
894 { "",
895 { 0xd9a, 0xdd9, 0xdcf, 0 },
896 { 0x4a, 0x61, 0x42, 0 }
897 },
898 { "",
899 { 0xd9a, 0xdd9, 0xddf, 0 },
900 { 0x4a, 0x61, 0x50, 0 }
901 },
902 { "",
903 { 0xd9a, 0xdd9, 0xdca, 0 },
904 { 0x4a, 0x62, 0 }
905 },
906 { "",
907 { 0xd9a, 0xddc, 0xdca, 0 },
908 { 0x4a, 0x61, 0x42, 0x41, 0 }
909 },
910 { "",
911 { 0xd9a, 0xdda, 0 },
912 { 0x4a, 0x62, 0 }
913 },
914 { "",
915 { 0xd9a, 0xddd, 0 },
916 { 0x4a, 0x61, 0x42, 0x41, 0 }
917 },
918 {{0}}
919 }
920};
921
922static const test_set_t tests_khmer = {
Behdad Esfahbod9704f0c2011-06-28 16:15:46 -0400923 {"KhmerOS.ttf", 0},
Behdad Esfahboda346e922011-06-28 12:49:18 -0400924 {
925 { "",
926 { 0x179a, 0x17cd, 0 },
927 { 0x24c, 0x27f, 0 }
928 },
929 { "",
930 { 0x179f, 0x17c5, 0 },
931 { 0x273, 0x203, 0 }
932 },
933 { "",
934 { 0x1790, 0x17d2, 0x1784, 0x17c3, 0 },
935 { 0x275, 0x242, 0x182, 0 }
936 },
937 { "",
938 { 0x179a, 0 },
939 { 0x24c, 0 }
940 },
941 { "",
942 { 0x1781, 0x17d2, 0x1798, 0x17c2, 0 },
943 { 0x274, 0x233, 0x197, 0 }
944 },
945 { "",
946 { 0x1798, 0x17b6, 0 },
947 { 0x1cb, 0 }
948 },
949 { "",
950 { 0x179a, 0x17b8, 0 },
951 { 0x24c, 0x26a, 0 }
952 },
953 { "",
954 { 0x1787, 0x17b6, 0 },
955 { 0x1ba, 0 }
956 },
957 { "",
958 { 0x1798, 0x17d2, 0x1796, 0x17bb, 0 },
959 { 0x24a, 0x195, 0x26d, 0 }
960 },
961 {{0}}
962 }
963};
964
965static const test_set_t tests_nko = {
Behdad Esfahbod9704f0c2011-06-28 16:15:46 -0400966 {"DejaVuSans.ttf", 0},
Behdad Esfahboda346e922011-06-28 12:49:18 -0400967 {
968 { "",
969 { 0x7ca, 0 },
970 { 0x5c1, 0 }
971 },
972 { "",
973 { 0x7ca, 0x7ca, 0 },
974 { 0x14db, 0x14d9, 0 }
975 },
976 { "",
977 { 0x7ca, 0x7fa, 0x7ca, 0 },
978 { 0x14db, 0x5ec, 0x14d9, 0 }
979 },
980 { "",
981 { 0x7ca, 0x7f3, 0x7ca, 0 },
982 { 0x14db, 0x5e7, 0x14d9, 0 }
983 },
984 { "",
985 { 0x7ca, 0x7f3, 0x7fa, 0x7ca, 0 },
986 { 0x14db, 0x5e7, 0x5ec, 0x14d9, 0 }
987 },
988 {{0}}
989 }
990};
991
992static const test_set_t tests_linearb = {
Behdad Esfahbod9704f0c2011-06-28 16:15:46 -0400993 {"penuture.ttf", 0},
Behdad Esfahboda346e922011-06-28 12:49:18 -0400994 {
995 { "",
996 { 0xd800, 0xdc01, 0xd800, 0xdc02, 0xd800, 0xdc03, 0 },
997 { 0x5, 0x6, 0x7, 0 },
998 },
999 {{0}}
1000 }
1001};
1002
1003
1004
Behdad Esfahbod42d453b2011-06-28 16:59:16 -04001005
1006
Behdad Esfahboda346e922011-06-28 12:49:18 -04001007typedef struct {
1008 FT_Library ft_library;
1009 FT_Face ft_face;
1010 hb_font_t *font;
1011} ft_fixture_t;
1012
1013static void
1014ft_fixture_init (ft_fixture_t *f, gconstpointer user_data)
1015{
Behdad Esfahbod42d453b2011-06-28 16:59:16 -04001016 const test_t *test = user_data;
1017 char *font_file = get_font_file (test->font_data);
1018 FT_Error err;
Behdad Esfahboda346e922011-06-28 12:49:18 -04001019
1020 FT_Init_FreeType (&f->ft_library);
1021
Behdad Esfahbod42d453b2011-06-28 16:59:16 -04001022 err = FT_New_Face (f->ft_library, font_file, test->font_data->face_index, &f->ft_face);
1023 g_assert_cmpint (err, ==, 0);
1024
1025 f->font = hb_ft_font_create (f->ft_face, NULL);
Behdad Esfahboda346e922011-06-28 12:49:18 -04001026
1027 g_free (font_file);
1028}
1029
1030static void
1031ft_fixture_finish (ft_fixture_t *f, gconstpointer user_data)
1032{
1033 hb_font_destroy (f->font);
1034
1035 FT_Done_Face (f->ft_face);
1036 FT_Done_FreeType (f->ft_library);
1037}
1038
1039static void
1040test_shape_complex (ft_fixture_t *f, gconstpointer user_data)
1041{
Behdad Esfahbod42d453b2011-06-28 16:59:16 -04001042 const test_t *test = user_data;
1043 const test_data_t *data = test->test_data;
1044 hb_buffer_t *buffer;
1045 unsigned int i, len, expected_len;
1046 hb_glyph_info_t *glyphs;
Behdad Esfahbodafa74bf2011-06-28 17:25:17 -04001047 hb_bool_t fail;
Behdad Esfahboda346e922011-06-28 12:49:18 -04001048
Behdad Esfahbod42d453b2011-06-28 16:59:16 -04001049 g_assert (f->font);
Behdad Esfahboda346e922011-06-28 12:49:18 -04001050
Behdad Esfahbod42d453b2011-06-28 16:59:16 -04001051 if (data->comments[0])
1052 g_test_message ("Test comments: %s", data->comments);
Behdad Esfahboda346e922011-06-28 12:49:18 -04001053
Behdad Esfahbod42d453b2011-06-28 16:59:16 -04001054 buffer = hb_buffer_create (0);
1055 for (len = 0; data->characters[len]; len++) ;
1056 hb_buffer_add_utf32 (buffer, data->characters, len, 0, len);
Behdad Esfahboda346e922011-06-28 12:49:18 -04001057
Behdad Esfahbod42d453b2011-06-28 16:59:16 -04001058 hb_shape (f->font, buffer, NULL, 0);
Behdad Esfahboda346e922011-06-28 12:49:18 -04001059
Behdad Esfahbod42d453b2011-06-28 16:59:16 -04001060 for (len = 0; data->glyphs[len]; len++) ;
1061 expected_len = len;
Behdad Esfahboda346e922011-06-28 12:49:18 -04001062
Behdad Esfahbod42d453b2011-06-28 16:59:16 -04001063 glyphs = hb_buffer_get_glyph_infos (buffer, &len);
Behdad Esfahbodafa74bf2011-06-28 17:25:17 -04001064 fail = len != expected_len;
1065 if (!fail)
1066 for (i = 0; i < len; i++)
1067 if (glyphs[i].codepoint != data->glyphs[i]) {
1068 fail = TRUE;
1069 break;
1070 }
1071
1072 if (fail) {
1073 GString *str = g_string_new ("");
1074 for (i = 0; i < expected_len; i++)
1075 g_string_append_printf (str, " %4d", data->glyphs[i]);
1076 g_test_message ("Expected glyphs: %s", str->str);
1077 g_string_truncate (str, 0);
1078 for (i = 0; i < len; i++)
1079 g_string_append_printf (str, " %4d", glyphs[i].codepoint);
1080 g_test_message ("Received glyphs: %s", str->str);
1081 g_string_free (str, TRUE);
1082
1083 g_test_fail ();
1084 }
Behdad Esfahboda346e922011-06-28 12:49:18 -04001085
Behdad Esfahbod42d453b2011-06-28 16:59:16 -04001086 hb_buffer_destroy (buffer);
Behdad Esfahboda346e922011-06-28 12:49:18 -04001087}
1088
Behdad Esfahbod42d453b2011-06-28 16:59:16 -04001089static void
1090test_shape_complex_skipped (gconstpointer user_data)
1091{
1092 const test_t *test = user_data;
1093 const test_data_t *data = test->test_data;
1094
1095 if (data->comments[0])
1096 g_test_message ("Test comments: %s", data->comments);
1097
1098 g_test_message ("Skipping test");
1099}
Behdad Esfahboda346e922011-06-28 12:49:18 -04001100
1101
Behdad Esfahbod27413162011-06-28 16:21:31 -04001102static void
1103add_test_set (const test_set_t *test_set, const char *set_name)
1104{
Behdad Esfahbod42d453b2011-06-28 16:59:16 -04001105 const test_data_t *data;
1106 char *font_file;
1107 hb_bool_t skip;
Behdad Esfahbod27413162011-06-28 16:21:31 -04001108
Behdad Esfahbod42d453b2011-06-28 16:59:16 -04001109 font_file = get_font_file (&test_set->font_data);
1110 skip = !g_file_test (font_file, G_FILE_TEST_EXISTS);
1111 g_free (font_file);
1112
1113 for (data = test_set->test_datas; data->characters[0]; data++) {
1114 char *flavor;
1115 GString *str;
1116 const hb_codepoint_t *p;
1117
1118 test_t *test = g_slice_new0 (test_t);
1119 test->font_data = &test_set->font_data;
1120 test->test_data = data;
1121
1122 str = g_string_new ("<");
1123 for (p = data->characters; *p; p++)
1124 g_string_append_printf (str, "%04X,", *p);
1125 str->str[str->len - 1] = '>';
1126
1127 flavor = g_strdup_printf ("%s/%s/%s", set_name, test_set->font_data.font_file, str->str);
1128
1129 g_string_free (str, TRUE);
1130
1131 if (skip)
1132 hb_test_add_data_flavor ((const void *) test, flavor, test_shape_complex_skipped);
1133 else
1134 hb_test_add_fixture_flavor (ft_fixture, (const void *) test, flavor, test_shape_complex);
1135
1136 g_free (flavor);
1137 }
Behdad Esfahbod27413162011-06-28 16:21:31 -04001138}
1139
Behdad Esfahboda346e922011-06-28 12:49:18 -04001140
1141int
1142main (int argc, char **argv)
1143{
1144 hb_test_init (&argc, &argv);
1145
Behdad Esfahbod27413162011-06-28 16:21:31 -04001146#define TEST_SET(name) add_test_set (&tests_##name, #name)
Behdad Esfahboda346e922011-06-28 12:49:18 -04001147
1148 TEST_SET (greek);
1149
Behdad Esfahbod42d453b2011-06-28 16:59:16 -04001150 TEST_SET (devanagari1);
1151 TEST_SET (devanagari2);
1152 TEST_SET (bengali1);
1153 TEST_SET (bengali2);
1154 TEST_SET (bengali3);
Behdad Esfahboda346e922011-06-28 12:49:18 -04001155 TEST_SET (gurmukhi);
1156 TEST_SET (oriya);
1157 TEST_SET (tamil);
1158 TEST_SET (telugu);
Behdad Esfahbod42d453b2011-06-28 16:59:16 -04001159 TEST_SET (kannada1);
1160 TEST_SET (kannada2);
1161 TEST_SET (malayalam1);
1162 TEST_SET (malayalam2);
Behdad Esfahboda346e922011-06-28 12:49:18 -04001163 TEST_SET (sinhala);
1164
1165 TEST_SET (khmer);
1166
1167 TEST_SET (nko);
1168 TEST_SET (linearb);
1169
1170 return hb_test_run();
1171}