From 86c40b3a1d8c7d970ce1b450f4dfadef8d9d0126 Mon Sep 17 00:00:00 2001 From: Ebrahim Byagowi Date: Sat, 29 Feb 2020 14:11:46 +0330 Subject: [PATCH] [fuzz/draw] Call _get_glyph_extents Other render related APIs also may be added also later such as ot-color and future rendering things. --- test/fuzzing/hb-draw-fuzzer.cc | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/test/fuzzing/hb-draw-fuzzer.cc b/test/fuzzing/hb-draw-fuzzer.cc index a4178084a..e12a3626d 100644 --- a/test/fuzzing/hb-draw-fuzzer.cc +++ b/test/fuzzing/hb-draw-fuzzer.cc @@ -109,11 +109,20 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) hb_draw_funcs_set_quadratic_to_func (funcs, (hb_draw_quadratic_to_func_t) _quadratic_to); hb_draw_funcs_set_cubic_to_func (funcs, (hb_draw_cubic_to_func_t) _cubic_to); hb_draw_funcs_set_close_path_func (funcs, (hb_draw_close_path_func_t) _close_path); - for (unsigned i = 0; i < glyph_count; ++i) + volatile unsigned counter = !glyph_count; + for (unsigned gid = 0; gid < glyph_count; ++gid) { - hb_font_draw_glyph (font, i, funcs, &user_data); + hb_font_draw_glyph (font, gid, funcs, &user_data); assert (!user_data.is_open); + + /* Glyph extents also may practices the similar path, call it now that is related */ + hb_glyph_extents_t extents; + if (hb_font_get_glyph_extents (font, gid, &extents)) + counter += !!extents.width + !!extents.height + !!extents.x_bearing + !!extents.y_bearing; + + if (!counter) counter += 1; } + assert (counter); hb_draw_funcs_destroy (funcs); hb_font_destroy (font);