diff --git a/src/hb-subset-input.cc b/src/hb-subset-input.cc index 9e91b08db..2c483e9f5 100644 --- a/src/hb-subset-input.cc +++ b/src/hb-subset-input.cc @@ -448,7 +448,7 @@ hb_subset_input_set_retain_all_features (hb_subset_input_t *subset_input, hb_bool_t hb_subset_input_get_retain_all_features (hb_subset_input_t *subset_input) { - return hb_subset_input_get_flags (subset_input) & HB_SUBSET_FLAGS_RETAIN_ALL_FEATURES; + return (bool) (hb_subset_input_get_flags (subset_input) & HB_SUBSET_FLAGS_RETAIN_ALL_FEATURES); } void @@ -463,7 +463,7 @@ hb_subset_input_set_drop_hints (hb_subset_input_t *subset_input, hb_bool_t hb_subset_input_get_drop_hints (hb_subset_input_t *subset_input) { - return hb_subset_input_get_flags (subset_input) & HB_SUBSET_FLAGS_NO_HINTING; + return (bool) (hb_subset_input_get_flags (subset_input) & HB_SUBSET_FLAGS_NO_HINTING); } void @@ -478,7 +478,7 @@ hb_subset_input_set_desubroutinize (hb_subset_input_t *subset_input, hb_bool_t hb_subset_input_get_desubroutinize (hb_subset_input_t *subset_input) { - return hb_subset_input_get_flags (subset_input) & HB_SUBSET_FLAGS_DESUBROUTINIZE; + return (bool) (hb_subset_input_get_flags (subset_input) & HB_SUBSET_FLAGS_DESUBROUTINIZE); } void @@ -493,7 +493,7 @@ hb_subset_input_set_retain_gids (hb_subset_input_t *subset_input, hb_bool_t hb_subset_input_get_retain_gids (hb_subset_input_t *subset_input) { - return hb_subset_input_get_flags (subset_input) & HB_SUBSET_FLAGS_RETAIN_GIDS; + return (bool) (hb_subset_input_get_flags (subset_input) & HB_SUBSET_FLAGS_RETAIN_GIDS); } void @@ -508,7 +508,7 @@ hb_subset_input_set_name_legacy (hb_subset_input_t *subset_input, hb_bool_t hb_subset_input_get_name_legacy (hb_subset_input_t *subset_input) { - return hb_subset_input_get_flags (subset_input) & HB_SUBSET_FLAGS_NAME_LEGACY; + return (bool) (hb_subset_input_get_flags (subset_input) & HB_SUBSET_FLAGS_NAME_LEGACY); } void @@ -523,7 +523,7 @@ hb_subset_input_set_overlaps_flag (hb_subset_input_t *subset_input, hb_bool_t hb_subset_input_get_overlaps_flag (hb_subset_input_t *subset_input) { - return hb_subset_input_get_flags (subset_input) & HB_SUBSET_FLAGS_SET_OVERLAPS_FLAG; + return (bool) (hb_subset_input_get_flags (subset_input) & HB_SUBSET_FLAGS_SET_OVERLAPS_FLAG); } void @@ -538,7 +538,7 @@ hb_subset_input_set_notdef_outline (hb_subset_input_t *subset_input, hb_bool_t hb_subset_input_get_notdef_outline (hb_subset_input_t *subset_input) { - return hb_subset_input_get_flags (subset_input) & HB_SUBSET_FLAGS_NOTDEF_OUTLINE; + return (bool) (hb_subset_input_get_flags (subset_input) & HB_SUBSET_FLAGS_NOTDEF_OUTLINE); } void @@ -554,5 +554,5 @@ hb_subset_input_set_no_prune_unicode_ranges (hb_subset_input_t *subset_input, hb_bool_t hb_subset_input_get_no_prune_unicode_ranges (hb_subset_input_t *subset_input) { - return hb_subset_input_get_flags (subset_input) & HB_SUBSET_FLAGS_NO_PRUNE_UNICODE_RANGES; + return (bool) (hb_subset_input_get_flags (subset_input) & HB_SUBSET_FLAGS_NO_PRUNE_UNICODE_RANGES); } diff --git a/test/api/test-subset.c b/test/api/test-subset.c index e4fa8cd1e..31a03d180 100644 --- a/test/api/test-subset.c +++ b/test/api/test-subset.c @@ -126,6 +126,56 @@ test_subset_set_flags (void) hb_subset_input_destroy (input); } + +static void +test_subset_legacy_api (void) +{ + hb_subset_input_t *input = hb_subset_input_create_or_fail (); + + g_assert (hb_subset_input_get_flags (input) == HB_SUBSET_FLAGS_DEFAULT); + + hb_subset_input_set_flags (input, + HB_SUBSET_FLAGS_NAME_LEGACY | + HB_SUBSET_FLAGS_NOTDEF_OUTLINE); + + g_assert (hb_subset_input_get_name_legacy (input)); + g_assert (hb_subset_input_get_notdef_outline (input)); + g_assert (!hb_subset_input_get_desubroutinize (input)); + g_assert (!hb_subset_input_get_drop_hints (input)); + + hb_subset_input_set_drop_hints (input, true); + hb_subset_input_set_name_legacy (input, false); + g_assert (!hb_subset_input_get_name_legacy (input)); + g_assert (hb_subset_input_get_notdef_outline (input)); + g_assert (!hb_subset_input_get_desubroutinize (input)); + g_assert (hb_subset_input_get_drop_hints (input)); + + + hb_face_t *face_abc = hb_test_open_font_file ("fonts/Roboto-Regular.abc.ttf"); + + hb_set_t *codepoints = hb_set_create(); + hb_set_add (codepoints, 97); + hb_set_add (codepoints, 99); + hb_set_union (hb_subset_input_unicode_set (input), codepoints); + hb_set_destroy (codepoints); + + hb_face_t *face_abc_subset_new = hb_subset (face_abc, input); + hb_face_t *face_abc_subset_legacy = hb_subset_or_fail (face_abc, input); + + + hb_blob_t* a = hb_face_reference_blob (face_abc_subset_new); + hb_blob_t* b = hb_face_reference_blob (face_abc_subset_new); + hb_test_assert_blobs_equal (a, b); + + hb_blob_destroy (a); + hb_blob_destroy (b); + hb_face_destroy (face_abc_subset_new); + hb_face_destroy (face_abc_subset_legacy); + hb_face_destroy (face_abc); + + hb_subset_input_destroy (input); +} + int main (int argc, char **argv) { @@ -135,6 +185,7 @@ main (int argc, char **argv) hb_test_add (test_subset_no_inf_loop); hb_test_add (test_subset_crash); hb_test_add (test_subset_set_flags); + hb_test_add (test_subset_legacy_api); return hb_test_run(); }