diff --git a/util/options.cc b/util/options.cc index 4c65735f8..299466fe6 100644 --- a/util/options.cc +++ b/util/options.cc @@ -670,6 +670,17 @@ font_options_t::get_font (void) const blob = hb_blob_create_from_file (font_file); } + if (hb_blob_get_length (blob) == 0) + fail (false, "No such file or directory, or is empty"); + + unsigned int face_count = hb_face_count (blob); + + if (face_count == 0) + fail (false, "Not a font file"); // most likely + + if (face_index > face_count) + fail (false, "The requested font index wasn't available in the file"); + /* Create the face */ hb_face_t *face = hb_face_create (blob, face_index); hb_blob_destroy (blob);