diff --git a/src/hb-subset.cc b/src/hb-subset.cc index f10ef54db..7cea9f183 100644 --- a/src/hb-subset.cc +++ b/src/hb-subset.cc @@ -594,14 +594,20 @@ static void _attach_accelerator_data (hb_subset_plan_t* plan, * @input: input to use for the subsetting. * * Subsets a font according to provided input. Returns nullptr - * if the subset operation fails. + * if the subset operation fails or the face has no glyphs. * * Since: 2.9.0 **/ hb_face_t * hb_subset_or_fail (hb_face_t *source, const hb_subset_input_t *input) { - if (unlikely (!input || !source)) return hb_face_get_empty (); + if (unlikely (!input || !source)) return nullptr; + + if (unlikely (!source->get_num_glyphs ())) + { + DEBUG_MSG (SUBSET, nullptr, "No glyphs in source font."); + return nullptr; + } hb_subset_plan_t *plan = hb_subset_plan_create_or_fail (source, input); if (unlikely (!plan)) { diff --git a/test/api/test-subset.c b/test/api/test-subset.c index 08c911076..6c859946a 100644 --- a/test/api/test-subset.c +++ b/test/api/test-subset.c @@ -43,8 +43,7 @@ test_subset_32_tables (void) hb_set_add (codepoints, 'c'); subset = hb_subset_or_fail (face, input); - g_assert (subset); - g_assert (subset != hb_face_get_empty ()); + g_assert (!subset); hb_subset_input_destroy (input); hb_face_destroy (subset); @@ -194,7 +193,7 @@ test_subset_plan (void) } static hb_blob_t* -_ref_table (hb_face_t *face, hb_tag_t tag, void *user_data) +_ref_table (hb_face_t *, hb_tag_t tag, void *user_data) { return hb_face_reference_table ((hb_face_t*) user_data, tag); }