diff options
author | Behdad Esfahbod <behdad@behdad.org> | 2015-06-18 17:15:33 -0700 |
---|---|---|
committer | Behdad Esfahbod <behdad@behdad.org> | 2015-06-18 17:15:33 -0700 |
commit | b3a2f6afbac1956b65f29a17b9dc896e86135329 (patch) | |
tree | 130de775dec24d828a9fe0482937c9edd3761cdb /test | |
parent | a6446d44e6d04e1eeea994682e29f9cb6265f7f6 (diff) | |
download | harfbuzz-b3a2f6afbac1956b65f29a17b9dc896e86135329.tar.gz |
[test] Add test for cluster merging
Based on test from https://code.google.com/p/chromium/issues/detail?id=497578
Currently fails. Basically, if there's a default_ignorable at the
start of text, and font has no space glyph, we remove the default_ignorable,
and that makes the first char in text to correspond to no cluster.
Fix coming.
Diffstat (limited to 'test')
-rw-r--r-- | test/api/test-shape.c | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/test/api/test-shape.c b/test/api/test-shape.c index ccf6eed7..eb244072 100644 --- a/test/api/test-shape.c +++ b/test/api/test-shape.c @@ -139,6 +139,48 @@ test_shape (void) } static void +test_shape_clusters (void) +{ + hb_face_t *face; + hb_font_t *font; + hb_buffer_t *buffer; + unsigned int len; + hb_glyph_info_t *glyphs; + + face = hb_face_create (NULL, 0); + font = hb_font_create (face); + hb_face_destroy (face); + + buffer = hb_buffer_create (); + hb_buffer_set_direction (buffer, HB_DIRECTION_LTR); + { + /* https://code.google.com/p/chromium/issues/detail?id=497578 */ + hb_codepoint_t test[] = {0xFFF1, 0xF0B6}; + hb_buffer_add_utf32 (buffer, test, 2, 0, 2); + } + + hb_shape (font, buffer, NULL, 0); + + len = hb_buffer_get_length (buffer); + glyphs = hb_buffer_get_glyph_infos (buffer, NULL); + + { + const hb_codepoint_t output_glyphs[] = {0}; + const hb_position_t output_clusters[] = {0}; + unsigned int i; + g_assert_cmpint (len, ==, 1); + for (i = 0; i < len; i++) { + g_assert_cmphex (glyphs[i].codepoint, ==, output_glyphs[i]); + g_assert_cmphex (glyphs[i].cluster, ==, output_clusters[i]); + } + } + + hb_buffer_destroy (buffer); + hb_font_destroy (font); +} + + +static void test_shape_list (void) { const char **shapers = hb_shape_list_shapers (); @@ -157,6 +199,7 @@ main (int argc, char **argv) hb_test_init (&argc, &argv); hb_test_add (test_shape); + hb_test_add (test_shape_clusters); /* TODO test fallback shaper */ /* TODO test shaper_full */ hb_test_add (test_shape_list); |