src/gen-vowel-constraints.py | 4 -- src/hb-aat-layout-common.hh | 3 - src/hb-aat-layout-morx-table.hh | 3 - src/hb-ot-shape-complex-indic.cc | 1 src/hb-ot-shape-complex-khmer.cc | 1 src/hb-ot-shape-complex-myanmar.cc | 1 src/hb-ot-shape-complex-thai.cc | 3 - src/hb-ot-shape-complex-use.cc | 1 src/hb-ot-shape-complex-vowel-constraints.cc | 5 +- src/hb-ot-shape.cc | 1 test/api/test-font.c | 5 ++ test/api/test-ot-face.c | 49 ++++++++++++++++++++------- test/fuzzing/hb-shape-fuzzer.cc | 6 +++ 13 files changed, 54 insertions(+), 29 deletions(-)
New commits: commit bce437cf0b71e9b60bbf058eaf61593fed30ae33 Author: Behdad Esfahbod <[email protected]> Date: Sun Nov 4 02:47:34 2018 -0500 [test] Call test-ot-face.c test from hb-shape-fuzzer Should increase coverage... diff --git a/test/api/test-ot-face.c b/test/api/test-ot-face.c index ac3d7f18..da23fe59 100644 --- a/test/api/test-ot-face.c +++ b/test/api/test-ot-face.c @@ -24,16 +24,17 @@ * Google Author(s): Behdad Esfahbod */ +#ifndef TEST_OT_FACE_NO_MAIN #include "hb-test.h" +#endif #include <hb-ot.h> /* Unit tests for hb-ot-*.h */ static void -test_ot_face_empty (void) +test_face (hb_face_t *face) { - hb_face_t *face = hb_face_get_empty (); hb_font_t *font = hb_font_create (face); hb_ot_font_set_funcs (font); @@ -66,23 +67,23 @@ test_ot_face_empty (void) hb_ot_color_has_layers (face); hb_ot_color_glyph_get_layers (face, 0, 0, NULL, NULL); hb_ot_color_has_svg (face); - hb_ot_color_glyph_reference_svg (face, 0); + hb_blob_destroy (hb_ot_color_glyph_reference_svg (face, 0)); hb_ot_color_has_png (face); - hb_ot_color_glyph_reference_png (font, 0); + hb_blob_destroy (hb_ot_color_glyph_reference_png (font, 0)); hb_ot_layout_has_glyph_classes (face); hb_ot_layout_has_substitution (face); hb_ot_layout_has_positioning (face); hb_ot_math_has_data (face); - hb_ot_math_get_constant (font, 0); + hb_ot_math_get_constant (font, HB_OT_MATH_CONSTANT_MATH_LEADING); hb_ot_math_get_glyph_italics_correction (font, 0); hb_ot_math_get_glyph_top_accent_attachment (font, 0); hb_ot_math_is_glyph_extended_shape (face, 0); - hb_ot_math_get_glyph_kerning (font, 0, 0, 0); - hb_ot_math_get_glyph_variants (font, 0, 0, 0, NULL, NULL); - hb_ot_math_get_min_connector_overlap (font, 0); - hb_ot_math_get_glyph_assembly (font, 0, 0, 0, NULL, NULL, NULL); + hb_ot_math_get_glyph_kerning (font, 0, HB_OT_MATH_KERN_BOTTOM_RIGHT, 0); + hb_ot_math_get_glyph_variants (font, 0, HB_DIRECTION_TTB, 0, NULL, NULL); + hb_ot_math_get_min_connector_overlap (font, HB_DIRECTION_RTL); + hb_ot_math_get_glyph_assembly (font, 0, HB_DIRECTION_BTT, 0, NULL, NULL, NULL); unsigned int len = sizeof (buf); hb_ot_name_list_names (face, NULL); @@ -97,7 +98,13 @@ test_ot_face_empty (void) hb_set_destroy (set); hb_font_destroy (font); - hb_face_destroy (face); +} + +#ifndef TEST_OT_FACE_NO_MAIN +static void +test_ot_face_empty (void) +{ + test_face (hb_face_get_empty ()); } int @@ -109,3 +116,4 @@ main (int argc, char **argv) return hb_test_run(); } +#endif diff --git a/test/fuzzing/hb-shape-fuzzer.cc b/test/fuzzing/hb-shape-fuzzer.cc index e8bc186b..fedf56e2 100644 --- a/test/fuzzing/hb-shape-fuzzer.cc +++ b/test/fuzzing/hb-shape-fuzzer.cc @@ -3,6 +3,10 @@ #include <hb-ot.h> #include <string.h> +#define TEST_OT_FACE_NO_MAIN 1 +#include "../api/test-ot-face.c" +#undef TEST_OT_FACE_NO_MAIN + extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { hb_blob_t *blob = hb_blob_create ((const char *)data, size, @@ -48,6 +52,8 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) hb_buffer_destroy (buffer); } + /* Misc calls on face. */ + test_face (face); hb_font_destroy (font); hb_face_destroy (face); commit 777c22425cae97009ca4dc5b1e400670c4aa0799 Author: Behdad Esfahbod <[email protected]> Date: Sun Nov 4 02:40:20 2018 -0500 [test] More funcs in test-ot-face diff --git a/test/api/test-font.c b/test/api/test-font.c index 3d81cf96..a92d8b26 100644 --- a/test/api/test-font.c +++ b/test/api/test-font.c @@ -536,6 +536,11 @@ test_font_properties (void) g_assert_cmpint (x_ppem, ==, 17); g_assert_cmpint (y_ppem, ==, 19); + /* Check ptem */ + g_assert_cmpint (hb_font_get_ptem (font), ==, 0); + hb_font_set_ptem (font, 42); + g_assert_cmpint (hb_font_get_ptem (font), ==, 42); + /* Check immutable */ diff --git a/test/api/test-ot-face.c b/test/api/test-ot-face.c index 0af584e0..ac3d7f18 100644 --- a/test/api/test-ot-face.c +++ b/test/api/test-ot-face.c @@ -35,12 +35,28 @@ test_ot_face_empty (void) { hb_face_t *face = hb_face_get_empty (); hb_font_t *font = hb_font_create (face); - hb_set_t *set = hb_set_create (); + hb_ot_font_set_funcs (font); + hb_set_t *set = hb_set_create (); hb_face_collect_unicodes (face, set); hb_face_collect_variation_selectors (face, set); hb_face_collect_variation_unicodes (face, 0, set); + hb_codepoint_t g; + hb_position_t x, y; + hb_glyph_extents_t extents; + char buf[5] = {0}; + hb_font_get_nominal_glyph (font, 0, &g); + hb_font_get_variation_glyph (font, 0, 0, &g); + hb_font_get_glyph_h_advance (font, g); + hb_font_get_glyph_v_advance (font, g); + hb_font_get_glyph_h_origin (font, g, &x, &y); + hb_font_get_glyph_v_origin (font, g, &x, &y); + hb_font_get_glyph_extents (font, g, &extents); + hb_font_get_glyph_contour_point (font, g, 0, &x, &y); + hb_font_get_glyph_name (font, g, buf, sizeof (buf)); + hb_font_get_glyph_from_name (font, buf, strlen (buf), &g); + hb_ot_color_has_palettes (face); hb_ot_color_palette_get_count (face); hb_ot_color_palette_get_name_id (face, 0); @@ -68,8 +84,9 @@ test_ot_face_empty (void) hb_ot_math_get_min_connector_overlap (font, 0); hb_ot_math_get_glyph_assembly (font, 0, 0, 0, NULL, NULL, NULL); + unsigned int len = sizeof (buf); hb_ot_name_list_names (face, NULL); - hb_ot_name_get_utf8 (face, 0, NULL, NULL, NULL); + hb_ot_name_get_utf8 (face, 0, NULL, &len, buf); hb_ot_name_get_utf16 (face, 0, NULL, NULL, NULL); hb_ot_name_get_utf32 (face, 0, NULL, NULL, NULL); commit 17335a8161e674e630287e18a6d304ec0c33767c Author: Behdad Esfahbod <[email protected]> Date: Sun Nov 4 02:25:07 2018 -0500 Clean up buffer->swap_buffers() calls That function checks for buffer->successful already. No need to check at call site. diff --git a/src/gen-vowel-constraints.py b/src/gen-vowel-constraints.py index c4e75aa9..b7f6be22 100755 --- a/src/gen-vowel-constraints.py +++ b/src/gen-vowel-constraints.py @@ -211,9 +211,7 @@ print (' }') print (' if (processed)') print (' {') print (' if (buffer->idx < count)') -print (' buffer->next_glyph ();') -print (' if (likely (buffer->successful))') -print (' buffer->swap_buffers ();') +print (' buffer->next_glyph ();') print (' }') print ('}') diff --git a/src/hb-aat-layout-common.hh b/src/hb-aat-layout-common.hh index 51add221..11c6c5a8 100644 --- a/src/hb-aat-layout-common.hh +++ b/src/hb-aat-layout-common.hh @@ -671,8 +671,7 @@ struct StateTableDriver { for (; buffer->successful && buffer->idx < buffer->len;) buffer->next_glyph (); - if (likely (buffer->successful)) - buffer->swap_buffers (); + buffer->swap_buffers (); } } diff --git a/src/hb-aat-layout-morx-table.hh b/src/hb-aat-layout-morx-table.hh index dab6ec1e..2bc60182 100644 --- a/src/hb-aat-layout-morx-table.hh +++ b/src/hb-aat-layout-morx-table.hh @@ -1121,8 +1121,7 @@ struct mortmorx else buffer->next_glyph (); } - if (likely (buffer->successful)) - buffer->swap_buffers (); + buffer->swap_buffers (); } inline void apply (hb_aat_apply_context_t *c) const diff --git a/src/hb-ot-shape-complex-indic.cc b/src/hb-ot-shape-complex-indic.cc index 4f98f748..8933c182 100644 --- a/src/hb-ot-shape-complex-indic.cc +++ b/src/hb-ot-shape-complex-indic.cc @@ -1018,7 +1018,6 @@ insert_dotted_circles (const hb_ot_shape_plan_t *plan HB_UNUSED, else buffer->next_glyph (); } - buffer->swap_buffers (); } diff --git a/src/hb-ot-shape-complex-khmer.cc b/src/hb-ot-shape-complex-khmer.cc index 1142da3e..497891ea 100644 --- a/src/hb-ot-shape-complex-khmer.cc +++ b/src/hb-ot-shape-complex-khmer.cc @@ -414,7 +414,6 @@ insert_dotted_circles (const hb_ot_shape_plan_t *plan HB_UNUSED, else buffer->next_glyph (); } - buffer->swap_buffers (); } diff --git a/src/hb-ot-shape-complex-myanmar.cc b/src/hb-ot-shape-complex-myanmar.cc index dcada261..ca7b5a9b 100644 --- a/src/hb-ot-shape-complex-myanmar.cc +++ b/src/hb-ot-shape-complex-myanmar.cc @@ -343,7 +343,6 @@ insert_dotted_circles (const hb_ot_shape_plan_t *plan HB_UNUSED, else buffer->next_glyph (); } - buffer->swap_buffers (); } diff --git a/src/hb-ot-shape-complex-thai.cc b/src/hb-ot-shape-complex-thai.cc index b687fe61..650c9800 100644 --- a/src/hb-ot-shape-complex-thai.cc +++ b/src/hb-ot-shape-complex-thai.cc @@ -357,8 +357,7 @@ preprocess_text_thai (const hb_ot_shape_plan_t *plan, buffer->merge_out_clusters (start - 1, end); } } - if (likely (buffer->successful)) - buffer->swap_buffers (); + buffer->swap_buffers (); /* If font has Thai GSUB, we are done. */ if (plan->props.script == HB_SCRIPT_THAI && !plan->map.found_script[0]) diff --git a/src/hb-ot-shape-complex-use.cc b/src/hb-ot-shape-complex-use.cc index 3ab77fc5..af25b07f 100644 --- a/src/hb-ot-shape-complex-use.cc +++ b/src/hb-ot-shape-complex-use.cc @@ -552,7 +552,6 @@ insert_dotted_circles (const hb_ot_shape_plan_t *plan HB_UNUSED, else buffer->next_glyph (); } - buffer->swap_buffers (); } diff --git a/src/hb-ot-shape-complex-vowel-constraints.cc b/src/hb-ot-shape-complex-vowel-constraints.cc index 20af8711..0e532581 100644 --- a/src/hb-ot-shape-complex-vowel-constraints.cc +++ b/src/hb-ot-shape-complex-vowel-constraints.cc @@ -429,9 +429,8 @@ _hb_preprocess_text_vowel_constraints (const hb_ot_shape_plan_t *plan HB_UNUSED, if (processed) { if (buffer->idx < count) - buffer->next_glyph (); - if (likely (buffer->successful)) - buffer->swap_buffers (); + buffer->next_glyph (); + buffer->swap_buffers (); } } diff --git a/src/hb-ot-shape.cc b/src/hb-ot-shape.cc index b687996f..8c5e38e0 100644 --- a/src/hb-ot-shape.cc +++ b/src/hb-ot-shape.cc @@ -425,7 +425,6 @@ hb_insert_dotted_circle (hb_buffer_t *buffer, hb_font_t *font) buffer->output_info (info); while (buffer->idx < buffer->len && buffer->successful) buffer->next_glyph (); - buffer->swap_buffers (); } _______________________________________________ HarfBuzz mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/harfbuzz
