[fuzzing] Fuzz glyph-id etc in test-ot-face

This commit is contained in:
Behdad Esfahbod 2018-11-05 15:03:18 -05:00
parent 252632c477
commit 6482fda519
2 changed files with 30 additions and 46 deletions

View File

@ -33,7 +33,8 @@
static void
test_face (hb_face_t *face)
test_face (hb_face_t *face,
hb_codepoint_t cp)
{
hb_font_t *font = hb_font_create (face);
hb_ot_font_set_funcs (font);
@ -41,35 +42,35 @@ test_face (hb_face_t *face)
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_face_collect_variation_unicodes (face, cp, 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_nominal_glyph (font, cp, &g);
hb_font_get_variation_glyph (font, cp, cp, &g);
hb_font_get_glyph_h_advance (font, cp);
hb_font_get_glyph_v_advance (font, cp);
hb_font_get_glyph_h_origin (font, cp, &x, &y);
hb_font_get_glyph_v_origin (font, cp, &x, &y);
hb_font_get_glyph_extents (font, cp, &extents);
hb_font_get_glyph_contour_point (font, cp, 0, &x, &y);
hb_font_get_glyph_name (font, cp, 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);
hb_ot_color_palette_color_get_name_id (face, 0);
hb_ot_color_palette_get_flags (face, 0);
hb_ot_color_palette_get_colors (face, 0, 0, NULL, NULL);
hb_ot_color_palette_get_name_id (face, cp);
hb_ot_color_palette_color_get_name_id (face, cp);
hb_ot_color_palette_get_flags (face, cp);
hb_ot_color_palette_get_colors (face, cp, 0, NULL, NULL);
hb_ot_color_has_layers (face);
hb_ot_color_glyph_get_layers (face, 0, 0, NULL, NULL);
hb_ot_color_glyph_get_layers (face, cp, 0, NULL, NULL);
hb_ot_color_has_svg (face);
hb_blob_destroy (hb_ot_color_glyph_reference_svg (face, 0));
hb_blob_destroy (hb_ot_color_glyph_reference_svg (face, cp));
hb_ot_color_has_png (face);
hb_blob_destroy (hb_ot_color_glyph_reference_png (font, 0));
hb_blob_destroy (hb_ot_color_glyph_reference_png (font, cp));
hb_ot_layout_has_glyph_classes (face);
hb_ot_layout_has_substitution (face);
@ -77,19 +78,19 @@ test_face (hb_face_t *face)
hb_ot_math_has_data (face);
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, 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_glyph_italics_correction (font, cp);
hb_ot_math_get_glyph_top_accent_attachment (font, cp);
hb_ot_math_is_glyph_extended_shape (face, cp);
hb_ot_math_get_glyph_kerning (font, cp, HB_OT_MATH_KERN_BOTTOM_RIGHT, 0);
hb_ot_math_get_glyph_variants (font, cp, 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);
hb_ot_math_get_glyph_assembly (font, cp, HB_DIRECTION_BTT, 0, NULL, NULL, NULL);
unsigned int len = sizeof (buf);
hb_ot_name_list_names (face, 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);
hb_ot_name_get_utf8 (face, cp, NULL, &len, buf);
hb_ot_name_get_utf16 (face, cp, NULL, NULL, NULL);
hb_ot_name_get_utf32 (face, cp, NULL, NULL, NULL);
hb_ot_var_get_axis_count (face);
hb_ot_var_get_axes (face, 0, NULL, NULL);
@ -104,7 +105,7 @@ test_face (hb_face_t *face)
static void
test_ot_face_empty (void)
{
test_face (hb_face_get_empty ());
test_face (hb_face_get_empty (), 0);
}
int

View File

@ -32,28 +32,11 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
hb_buffer_add_utf32 (buffer, text32, sizeof (text32) / sizeof (text32[0]), 0, -1);
hb_buffer_guess_segment_properties (buffer);
hb_shape (font, buffer, NULL, 0);
unsigned int len = hb_buffer_get_length (buffer);
hb_glyph_info_t *infos = hb_buffer_get_glyph_infos (buffer, NULL);
//hb_glyph_position_t *positions = hb_buffer_get_glyph_positions (buffer, NULL);
for (unsigned int i = 0; i < len; i++)
{
hb_glyph_info_t info = infos[i];
//hb_glyph_position_t pos = positions[i];
hb_glyph_extents_t extents;
hb_font_get_glyph_extents (font, info.codepoint, &extents);
hb_ot_color_glyph_get_layers (face, info.codepoint, 0, nullptr, nullptr);
hb_blob_destroy (hb_ot_color_glyph_reference_svg (face, info.codepoint));
hb_blob_destroy (hb_ot_color_glyph_reference_png (font, info.codepoint));
}
hb_buffer_destroy (buffer);
}
/* Misc calls on face. */
test_face (face);
test_face (face, text32[15]);
hb_font_destroy (font);
hb_face_destroy (face);