diff options
author | Behdad Esfahbod <behdad@behdad.org> | 2014-07-16 15:34:20 -0400 |
---|---|---|
committer | Behdad Esfahbod <behdad@behdad.org> | 2014-07-16 15:34:20 -0400 |
commit | 976c8f455221eb599d1c446eafd88d51d7d2aa65 (patch) | |
tree | d19f800fe6442515511bee1d15d6c257881dbc4d /test | |
parent | bcba8b45024e1eca8be77ca2657de1dc44dbf8fb (diff) | |
download | harfbuzz-976c8f455221eb599d1c446eafd88d51d7d2aa65.tar.gz |
New API: hb_buffer_[sg]et_replacement_codepoint()
With this change, we now by default replace broken UTF-8/16/32 bits
with U+FFFD. This can be changed by calling new API on the buffer.
Previously the replacement value used to be (hb_codepoint_t)-1.
Note that hb_buffer_clear_contents() does NOT reset the replacement
character.
See discussion here:
https://github.com/behdad/harfbuzz/commit/6f13b6d62daae4989e3cc2fe4b168e5c59650964
New API:
hb_buffer_set_replacement_codepoint()
hb_buffer_get_replacement_codepoint()
Diffstat (limited to 'test')
-rw-r--r-- | test/api/test-buffer.c | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/test/api/test-buffer.c b/test/api/test-buffer.c index 1be69317..af73c3f1 100644 --- a/test/api/test-buffer.c +++ b/test/api/test-buffer.c @@ -374,6 +374,7 @@ test_buffer_utf8_conversion (void) unsigned int bytes, chars, i, j, len; b = hb_buffer_create (); + hb_buffer_set_replacement_codepoint (b, (hb_codepoint_t) -1); for (i = 0; i < G_N_ELEMENTS (utf8_conversion_tests); i++) { @@ -388,7 +389,7 @@ test_buffer_utf8_conversion (void) for (chars = 0; test->codepoints[chars]; chars++) ; - hb_buffer_reset (b); + hb_buffer_clear_contents (b); hb_buffer_add_utf8 (b, test->utf8, bytes, 1, bytes - 2); glyphs = hb_buffer_get_glyph_infos (b, &len); @@ -660,6 +661,7 @@ test_buffer_utf8_validity (void) unsigned int i; b = hb_buffer_create (); + hb_buffer_set_replacement_codepoint (b, (hb_codepoint_t) -1); for (i = 0; i < G_N_ELEMENTS (utf8_validity_tests); i++) { @@ -678,7 +680,7 @@ test_buffer_utf8_validity (void) else segment_bytes = test->max_len; - hb_buffer_reset (b); + hb_buffer_clear_contents (b); hb_buffer_add_utf8 (b, test->utf8, text_bytes, 0, segment_bytes); glyphs = hb_buffer_get_glyph_infos (b, &len); @@ -718,6 +720,7 @@ test_buffer_utf16_conversion (void) unsigned int i; b = hb_buffer_create (); + hb_buffer_set_replacement_codepoint (b, (hb_codepoint_t) -1); for (i = 0; i < G_N_ELEMENTS (utf16_conversion_tests); i++) { @@ -732,7 +735,7 @@ test_buffer_utf16_conversion (void) for (chars = 0; test->codepoints[chars]; chars++) ; - hb_buffer_reset (b); + hb_buffer_clear_contents (b); hb_buffer_add_utf16 (b, test->utf16, u_len, 1, u_len - 2); glyphs = hb_buffer_get_glyph_infos (b, &len); @@ -752,15 +755,15 @@ typedef struct { /* note: we skip the first and last item from utf32 when adding to buffer */ static const utf32_conversion_test_t utf32_conversion_tests[] = { - {{0x41, 0x004D, 0x0430, 0x4E8C, 0xD800, 0xDF02, 0x61} , {0x004D, 0x0430, 0x4E8C, -1, -1}}, + {{0x41, 0x004D, 0x0430, 0x4E8C, 0xD800, 0xDF02, 0x61} , {0x004D, 0x0430, 0x4E8C, -3, -3}}, {{0x41, 0x004D, 0x0430, 0x4E8C, 0x10302, 0x61} , {0x004D, 0x0430, 0x4E8C, 0x10302}}, - {{0x41, 0xD800, 0xDF02, 0x61}, {-1, -1}}, - {{0x41, 0xD800, 0xDF02}, {-1}}, - {{0x41, 0x61, 0xD800, 0xDF02}, {0x61, -1}}, - {{0x41, 0xD800, 0x61, 0xDF02}, {-1, 0x61}}, - {{0x41, 0xDF00, 0x61}, {-1}}, + {{0x41, 0xD800, 0xDF02, 0x61}, {-3, -3}}, + {{0x41, 0xD800, 0xDF02}, {-3}}, + {{0x41, 0x61, 0xD800, 0xDF02}, {0x61, -3}}, + {{0x41, 0xD800, 0x61, 0xDF02}, {-3, 0x61}}, + {{0x41, 0xDF00, 0x61}, {-3}}, {{0x41, 0x10FFFF, 0x61}, {0x10FFFF}}, - {{0x41, 0x110000, 0x61}, {-1}}, + {{0x41, 0x110000, 0x61}, {-3}}, {{0x41, 0x61}, {0}} }; @@ -771,6 +774,7 @@ test_buffer_utf32_conversion (void) unsigned int i; b = hb_buffer_create (); + hb_buffer_set_replacement_codepoint (b, (hb_codepoint_t) -3); for (i = 0; i < G_N_ELEMENTS (utf32_conversion_tests); i++) { @@ -785,7 +789,7 @@ test_buffer_utf32_conversion (void) for (chars = 0; test->codepoints[chars]; chars++) ; - hb_buffer_reset (b); + hb_buffer_clear_contents (b); hb_buffer_add_utf32 (b, test->utf32, u_len, 1, u_len - 2); glyphs = hb_buffer_get_glyph_infos (b, &len); |