[subset] In preperation for 3.0.0 release remove legacy subsetting api methods.

This commit is contained in:
Garret Rieger 2021-09-16 11:23:09 -07:00 committed by Behdad Esfahbod
parent ae14537854
commit d700646c33
9 changed files with 25 additions and 354 deletions

View File

@ -269,75 +269,6 @@ hb_subset_input_glyph_set (hb_subset_input_t *input)
return input->sets.glyphs;
}
/**
* hb_subset_input_nameid_set:
* @input: a #hb_subset_input_t object.
*
* Gets the set of name table name IDs to retain, the caller should modify the
* set as needed.
*
* Return value: (transfer none): pointer to the #hb_set_t of name IDs.
*
* Since: 2.9.0
**/
HB_EXTERN hb_set_t *
hb_subset_input_nameid_set (hb_subset_input_t *input)
{
return input->sets.name_ids;
}
/**
* hb_subset_input_namelangid_set:
* @input: a #hb_subset_input_t object.
*
* Gets the set of name table language IDs to retain, the caller should modify
* the set as needed.
*
* Return value: (transfer none): pointer to the #hb_set_t of language IDs.
*
* Since: 2.9.0
**/
HB_EXTERN hb_set_t *
hb_subset_input_namelangid_set (hb_subset_input_t *input)
{
return input->sets.name_languages;
}
/**
* hb_subset_input_layout_features_set:
* @input: a #hb_subset_input_t object.
*
* Gets the set of layout feature tags to retain, the caller should modify the
* set as needed.
*
* Return value: (transfer none): pointer to the #hb_set_t of feature tags.
*
* Since: 2.9.0
**/
HB_EXTERN hb_set_t *
hb_subset_input_layout_features_set (hb_subset_input_t *input)
{
return input->sets.layout_features;
}
/**
* hb_subset_input_drop_tables_set:
* @input: a #hb_subset_input_t object.
*
* Gets the set of table tags to drop, the caller should modify the set as
* needed.
*
* Return value: (transfer none): pointer to the #hb_set_t of table tags.
*
* Since: 2.9.0
**/
HB_EXTERN hb_set_t *
hb_subset_input_drop_tables_set (hb_subset_input_t *input)
{
return input->sets.drop_tables;
}
/**
* hb_subset_input_set:
* @input: a #hb_subset_input_t object.
@ -355,24 +286,6 @@ hb_subset_input_set (hb_subset_input_t *input, hb_subset_sets_t set_type)
return input->sets_iter () [set_type];
}
/**
* hb_subset_input_no_subset_tables_set:
* @input: a #hb_subset_input_t object.
*
* Gets the set of table tags which specifies tables that should not be
* subsetted, the caller should modify the set as needed.
*
* Return value: (transfer none): pointer to the #hb_set_t of table tags.
*
* Since: 2.9.0
**/
HB_EXTERN hb_set_t *
hb_subset_input_no_subset_tables_set (hb_subset_input_t *input)
{
return input->sets.no_subset_tables;
}
/**
* hb_subset_input_get_flags:
* @input: a #hb_subset_input_t object.
@ -448,118 +361,3 @@ hb_subset_input_get_user_data (const hb_subset_input_t *input,
{
return hb_object_get_user_data (input, key);
}
static void set_flag_value (hb_subset_input_t *input, hb_subset_flags_t flag, hb_bool_t value)
{
hb_subset_input_set_flags (input,
value
? hb_subset_input_get_flags (input) | flag
: hb_subset_input_get_flags (input) & ~flag);
}
void
hb_subset_input_set_drop_hints (hb_subset_input_t *subset_input,
hb_bool_t drop_hints)
{
return set_flag_value (subset_input,
HB_SUBSET_FLAGS_NO_HINTING,
drop_hints);
}
hb_bool_t
hb_subset_input_get_drop_hints (hb_subset_input_t *subset_input)
{
return (bool) (hb_subset_input_get_flags (subset_input) & HB_SUBSET_FLAGS_NO_HINTING);
}
void
hb_subset_input_set_desubroutinize (hb_subset_input_t *subset_input,
hb_bool_t desubroutinize)
{
return set_flag_value (subset_input,
HB_SUBSET_FLAGS_DESUBROUTINIZE,
desubroutinize);
}
hb_bool_t
hb_subset_input_get_desubroutinize (hb_subset_input_t *subset_input)
{
return (bool) (hb_subset_input_get_flags (subset_input) & HB_SUBSET_FLAGS_DESUBROUTINIZE);
}
void
hb_subset_input_set_retain_gids (hb_subset_input_t *subset_input,
hb_bool_t retain_gids)
{
return set_flag_value (subset_input,
HB_SUBSET_FLAGS_RETAIN_GIDS,
retain_gids);
}
hb_bool_t
hb_subset_input_get_retain_gids (hb_subset_input_t *subset_input)
{
return (bool) (hb_subset_input_get_flags (subset_input) & HB_SUBSET_FLAGS_RETAIN_GIDS);
}
void
hb_subset_input_set_name_legacy (hb_subset_input_t *subset_input,
hb_bool_t name_legacy)
{
return set_flag_value (subset_input,
HB_SUBSET_FLAGS_NAME_LEGACY,
name_legacy);
}
hb_bool_t
hb_subset_input_get_name_legacy (hb_subset_input_t *subset_input)
{
return (bool) (hb_subset_input_get_flags (subset_input) & HB_SUBSET_FLAGS_NAME_LEGACY);
}
void
hb_subset_input_set_overlaps_flag (hb_subset_input_t *subset_input,
hb_bool_t overlaps_flag)
{
return set_flag_value (subset_input,
HB_SUBSET_FLAGS_SET_OVERLAPS_FLAG,
overlaps_flag);
}
hb_bool_t
hb_subset_input_get_overlaps_flag (hb_subset_input_t *subset_input)
{
return (bool) (hb_subset_input_get_flags (subset_input) & HB_SUBSET_FLAGS_SET_OVERLAPS_FLAG);
}
void
hb_subset_input_set_notdef_outline (hb_subset_input_t *subset_input,
hb_bool_t notdef_outline)
{
return set_flag_value (subset_input,
HB_SUBSET_FLAGS_NOTDEF_OUTLINE,
notdef_outline);
}
hb_bool_t
hb_subset_input_get_notdef_outline (hb_subset_input_t *subset_input)
{
return (bool) (hb_subset_input_get_flags (subset_input) & HB_SUBSET_FLAGS_NOTDEF_OUTLINE);
}
void
hb_subset_input_set_no_prune_unicode_ranges (hb_subset_input_t *subset_input,
hb_bool_t no_prune_unicode_ranges)
{
return set_flag_value (subset_input,
HB_SUBSET_FLAGS_NO_PRUNE_UNICODE_RANGES,
no_prune_unicode_ranges);
}
hb_bool_t
hb_subset_input_get_no_prune_unicode_ranges (hb_subset_input_t *subset_input)
{
return (bool) (hb_subset_input_get_flags (subset_input) & HB_SUBSET_FLAGS_NO_PRUNE_UNICODE_RANGES);
}

View File

@ -330,14 +330,6 @@ _subset_table (hb_subset_plan_t *plan, hb_tag_t tag)
}
}
hb_face_t *
hb_subset (hb_face_t *source, hb_subset_input_t *input)
{
hb_face_t* face = hb_subset_or_fail (source, input);
if (face) return face;
return hb_face_get_empty ();
}
/**
* hb_subset_or_fail:
* @source: font face data to be subset.

View File

@ -126,6 +126,12 @@ HB_EXTERN void *
hb_subset_input_get_user_data (const hb_subset_input_t *input,
hb_user_data_key_t *key);
HB_EXTERN hb_set_t *
hb_subset_input_unicode_set (hb_subset_input_t *input);
HB_EXTERN hb_set_t *
hb_subset_input_glyph_set (hb_subset_input_t *input);
HB_EXTERN hb_set_t *
hb_subset_input_set (hb_subset_input_t *input, hb_subset_sets_t set_type);
@ -139,82 +145,6 @@ hb_subset_input_set_flags (hb_subset_input_t *input,
HB_EXTERN hb_face_t *
hb_subset_or_fail (hb_face_t *source, const hb_subset_input_t *input);
/*
* ### Legacy API ###
* The methods below are part of the legacy harfbuzz subsetting API and will be
* Removed as of version 3.0.0
*/
HB_EXTERN void
hb_subset_input_set_drop_hints (hb_subset_input_t *subset_input,
hb_bool_t drop_hints);
HB_EXTERN hb_bool_t
hb_subset_input_get_drop_hints (hb_subset_input_t *subset_input);
HB_EXTERN void
hb_subset_input_set_desubroutinize (hb_subset_input_t *subset_input,
hb_bool_t desubroutinize);
HB_EXTERN hb_bool_t
hb_subset_input_get_desubroutinize (hb_subset_input_t *subset_input);
HB_EXTERN void
hb_subset_input_set_retain_gids (hb_subset_input_t *subset_input,
hb_bool_t retain_gids);
HB_EXTERN hb_bool_t
hb_subset_input_get_retain_gids (hb_subset_input_t *subset_input);
HB_EXTERN void
hb_subset_input_set_name_legacy (hb_subset_input_t *subset_input,
hb_bool_t name_legacy);
HB_EXTERN hb_bool_t
hb_subset_input_get_name_legacy (hb_subset_input_t *subset_input);
HB_EXTERN void
hb_subset_input_set_overlaps_flag (hb_subset_input_t *subset_input,
hb_bool_t overlaps_flag);
HB_EXTERN hb_bool_t
hb_subset_input_get_overlaps_flag (hb_subset_input_t *subset_input);
HB_EXTERN void
hb_subset_input_set_notdef_outline (hb_subset_input_t *subset_input,
hb_bool_t notdef_outline);
HB_EXTERN hb_bool_t
hb_subset_input_get_notdef_outline (hb_subset_input_t *subset_input);
HB_EXTERN void
hb_subset_input_set_no_prune_unicode_ranges (hb_subset_input_t *subset_input,
hb_bool_t no_prune_unicode_ranges);
HB_EXTERN hb_bool_t
hb_subset_input_get_no_prune_unicode_ranges (hb_subset_input_t *subset_input);
HB_EXTERN hb_set_t *
hb_subset_input_unicode_set (hb_subset_input_t *input);
HB_EXTERN hb_set_t *
hb_subset_input_glyph_set (hb_subset_input_t *input);
HB_EXTERN hb_set_t *
hb_subset_input_nameid_set (hb_subset_input_t *input);
HB_EXTERN hb_set_t *
hb_subset_input_namelangid_set (hb_subset_input_t *input);
HB_EXTERN hb_set_t *
hb_subset_input_layout_features_set (hb_subset_input_t *input);
HB_EXTERN hb_set_t *
hb_subset_input_no_subset_tables_set (hb_subset_input_t *input);
HB_EXTERN hb_set_t *
hb_subset_input_drop_tables_set (hb_subset_input_t *input);
HB_EXTERN hb_face_t *
hb_subset (hb_face_t *source, hb_subset_input_t *input);
HB_END_DECLS
#endif /* HB_SUBSET_H */

View File

@ -69,10 +69,10 @@ static inline hb_subset_input_t *
hb_subset_test_create_input_from_nameids (const hb_set_t *name_ids)
{
hb_subset_input_t *input = hb_subset_input_create_or_fail ();
hb_set_t * input_name_ids = hb_subset_input_nameid_set (input);
hb_set_t * input_name_ids = hb_subset_input_set (input, HB_SUBSET_SETS_NAME_ID);
hb_set_set (input_name_ids, name_ids);
hb_set_t *name_langids = hb_subset_input_namelangid_set (input);
hb_set_t *name_langids = hb_subset_input_set (input, HB_SUBSET_SETS_NAME_LANG_ID);
hb_set_add_range (name_langids, 0, 0x5FFF);
hb_subset_input_set_flags (input,

View File

@ -38,8 +38,8 @@ test_subset_drop_tables (void)
hb_set_add (codepoints, 97);
hb_set_add (codepoints, 99);
hb_subset_input_t *input = hb_subset_test_create_input (codepoints);
hb_set_add (hb_subset_input_drop_tables_set (input), HB_TAG ('h', 'd', 'm', 'x'));
hb_set_add (hb_subset_input_drop_tables_set (input), HB_TAG ('h', 'm', 't', 'x'));
hb_set_add (hb_subset_input_set (input, HB_SUBSET_SETS_DROP_TABLE_TAG), HB_TAG ('h', 'd', 'm', 'x'));
hb_set_add (hb_subset_input_set (input, HB_SUBSET_SETS_DROP_TABLE_TAG), HB_TAG ('h', 'm', 't', 'x'));
hb_set_destroy (codepoints);
hb_face_t* subset = hb_subset_or_fail (face, input);

View File

@ -162,9 +162,9 @@ test_subset_glyf_with_gsub (void)
input = hb_subset_test_create_input (codepoints);
hb_set_destroy (codepoints);
hb_set_del (hb_subset_input_drop_tables_set (input), HB_TAG('G', 'S', 'U', 'B'));
hb_set_del (hb_subset_input_drop_tables_set (input), HB_TAG('G', 'P', 'O', 'S'));
hb_set_del (hb_subset_input_drop_tables_set (input), HB_TAG('G', 'D', 'E', 'F'));
hb_set_del (hb_subset_input_set (input, HB_SUBSET_SETS_DROP_TABLE_TAG), HB_TAG('G', 'S', 'U', 'B'));
hb_set_del (hb_subset_input_set (input, HB_SUBSET_SETS_DROP_TABLE_TAG), HB_TAG('G', 'P', 'O', 'S'));
hb_set_del (hb_subset_input_set (input, HB_SUBSET_SETS_DROP_TABLE_TAG), HB_TAG('G', 'D', 'E', 'F'));
face_subset = hb_subset_test_create_subset (face_fil, input);
@ -191,9 +191,9 @@ test_subset_glyf_without_gsub (void)
input = hb_subset_test_create_input (codepoints);
hb_set_destroy (codepoints);
hb_set_add (hb_subset_input_drop_tables_set (input), HB_TAG('G', 'S', 'U', 'B'));
hb_set_add (hb_subset_input_drop_tables_set (input), HB_TAG('G', 'P', 'O', 'S'));
hb_set_add (hb_subset_input_drop_tables_set (input), HB_TAG('G', 'D', 'E', 'F'));
hb_set_add (hb_subset_input_set (input, HB_SUBSET_SETS_DROP_TABLE_TAG), HB_TAG('G', 'S', 'U', 'B'));
hb_set_add (hb_subset_input_set (input, HB_SUBSET_SETS_DROP_TABLE_TAG), HB_TAG('G', 'P', 'O', 'S'));
hb_set_add (hb_subset_input_set (input, HB_SUBSET_SETS_DROP_TABLE_TAG), HB_TAG('G', 'D', 'E', 'F'));
face_subset = hb_subset_test_create_subset (face_fil, input);

View File

@ -42,7 +42,8 @@ test_subset_gpos_lookup_subtable (void)
hb_subset_input_t *input = hb_subset_test_create_input (codepoints);
hb_set_del (hb_subset_input_drop_tables_set (input), HB_TAG ('G', 'P', 'O', 'S'));
hb_set_del (hb_subset_input_set (input, HB_SUBSET_SETS_DROP_TABLE_TAG),
HB_TAG ('G', 'P', 'O', 'S'));
face_pwa_subset = hb_subset_test_create_subset (face_pwa, input);
hb_set_destroy (codepoints);
@ -67,7 +68,8 @@ test_subset_gpos_pairpos1_vf (void)
hb_subset_input_t *input = hb_subset_test_create_input (codepoints);
hb_set_del (hb_subset_input_drop_tables_set (input), HB_TAG ('G', 'P', 'O', 'S'));
hb_set_del (hb_subset_input_set (input, HB_SUBSET_SETS_DROP_TABLE_TAG),
HB_TAG ('G', 'P', 'O', 'S'));
face_wav_subset = hb_subset_test_create_subset (face_wav, input);
hb_set_destroy (codepoints);

View File

@ -148,63 +148,13 @@ test_subset_sets (void)
hb_set_clear (set);
hb_set_add (set, 87);
g_assert (hb_set_is_equal (hb_subset_input_layout_features_set (input), set));
g_assert (hb_set_is_equal (hb_subset_input_set (input, HB_SUBSET_SETS_LAYOUT_FEATURE_TAG), set));
hb_set_clear (set);
hb_set_destroy (set);
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)
{
@ -215,7 +165,6 @@ main (int argc, char **argv)
hb_test_add (test_subset_crash);
hb_test_add (test_subset_set_flags);
hb_test_add (test_subset_sets);
hb_test_add (test_subset_legacy_api);
return hb_test_run();
}

View File

@ -418,7 +418,7 @@ parse_nameids (const char *name,
subset_main_t *subset_main = (subset_main_t *) data;
hb_bool_t is_remove = (name[strlen (name) - 1] == '-');
hb_bool_t is_add = (name[strlen (name) - 1] == '+');
hb_set_t *name_ids = hb_subset_input_nameid_set (subset_main->input);
hb_set_t *name_ids = hb_subset_input_set (subset_main->input, HB_SUBSET_SETS_NAME_ID);
if (!is_remove && !is_add) hb_set_clear (name_ids);
@ -472,7 +472,7 @@ parse_name_languages (const char *name,
subset_main_t *subset_main = (subset_main_t *) data;
hb_bool_t is_remove = (name[strlen (name) - 1] == '-');
hb_bool_t is_add = (name[strlen (name) - 1] == '+');
hb_set_t *name_languages = hb_subset_input_namelangid_set (subset_main->input);
hb_set_t *name_languages = hb_subset_input_set (subset_main->input, HB_SUBSET_SETS_NAME_LANG_ID);
if (!is_remove && !is_add) hb_set_clear (name_languages);
@ -540,7 +540,7 @@ parse_layout_features (const char *name,
subset_main_t *subset_main = (subset_main_t *) data;
hb_bool_t is_remove = (name[strlen (name) - 1] == '-');
hb_bool_t is_add = (name[strlen (name) - 1] == '+');
hb_set_t *layout_features = hb_subset_input_layout_features_set (subset_main->input);
hb_set_t *layout_features = hb_subset_input_set (subset_main->input, HB_SUBSET_SETS_LAYOUT_FEATURE_TAG);
if (!is_remove && !is_add) hb_set_clear (layout_features);
@ -584,7 +584,7 @@ parse_drop_tables (const char *name,
subset_main_t *subset_main = (subset_main_t *) data;
hb_bool_t is_remove = (name[strlen (name) - 1] == '-');
hb_bool_t is_add = (name[strlen (name) - 1] == '+');
hb_set_t *drop_tables = hb_subset_input_drop_tables_set (subset_main->input);
hb_set_t *drop_tables = hb_subset_input_set (subset_main->input, HB_SUBSET_SETS_DROP_TABLE_TAG);
if (!is_remove && !is_add) hb_set_clear (drop_tables);