[subset] switch ..._set_flags to not take a mask.

This commit is contained in:
Garret Rieger 2021-07-29 15:25:41 -07:00
parent 46d4a5e673
commit f9d8e4a976
14 changed files with 61 additions and 79 deletions

View File

@ -55,7 +55,7 @@ hb_subset_input_create_or_fail (void)
input->drop_tables = hb_set_create (); input->drop_tables = hb_set_create ();
input->no_subset_tables = hb_set_create (); input->no_subset_tables = hb_set_create ();
input->flags = HB_SUBSET_FLAGS_NONE; input->flags = HB_SUBSET_FLAGS_DEFAULT;
hb_tag_t default_drop_tables[] = { hb_tag_t default_drop_tables[] = {
// Layout disabled by default // Layout disabled by default
@ -357,36 +357,31 @@ hb_subset_input_no_subset_tables_set (hb_subset_input_t *input)
* hb_subset_input_get_flags: * hb_subset_input_get_flags:
* @input: a #hb_subset_input_t object. * @input: a #hb_subset_input_t object.
* *
* Return value: the subsetting flags bit array. * Return value: the subsetting flags bit field.
* *
* Since: REPLACE * Since: REPLACE
**/ **/
HB_EXTERN hb_subset_flags_t HB_EXTERN hb_subset_flags_t
hb_subset_input_get_flags (hb_subset_input_t *input) hb_subset_input_get_flags (hb_subset_input_t *input)
{ {
return input->flags; return (hb_subset_flags_t) input->flags;
} }
/** /**
* hb_subset_input_set_flags: * hb_subset_input_set_flags:
* @input: a #hb_subset_input_t object. * @input: a #hb_subset_input_t object.
* @flag: which flag to set. * @value: bit field of flags
* @mask: bit mask which specifies which flags to change.
* @value: bit set of new values for those flags.
* *
* Updates the flags specified by the mask to the values in value. * Set all of the flags in the input object to the values
* specified by the bit field.
* *
* Since: REPLACE * Since: REPLACE
**/ **/
HB_EXTERN void HB_EXTERN void
hb_subset_input_set_flags (hb_subset_input_t *input, hb_subset_input_set_flags (hb_subset_input_t *input,
hb_subset_flags_t mask, unsigned value)
hb_subset_flags_t value)
{ {
// Set desired flags. input->flags = (hb_subset_flags_t) value;
input->flags = (hb_subset_flags_t) (input->flags | (mask & value));
// Clear desired flags.
input->flags = (hb_subset_flags_t) (input->flags & ~(mask & ~value));
} }
/** /**

View File

@ -34,6 +34,8 @@
#include "hb-font.hh" #include "hb-font.hh"
HB_MARK_AS_FLAG_T (hb_subset_flags_t);
struct hb_subset_input_t struct hb_subset_input_t
{ {
hb_object_header_t header; hb_object_header_t header;
@ -46,7 +48,7 @@ struct hb_subset_input_t
hb_set_t *drop_tables; hb_set_t *drop_tables;
hb_set_t *layout_features; hb_set_t *layout_features;
hb_subset_flags_t flags; unsigned flags;
/* TODO /* TODO
* *

View File

@ -40,7 +40,7 @@ struct hb_subset_plan_t
hb_object_header_t header; hb_object_header_t header;
bool successful; bool successful;
hb_subset_flags_t flags; unsigned flags;
// For each cp that we'd like to retain maps to the corresponding gid. // For each cp that we'd like to retain maps to the corresponding gid.
hb_set_t *unicodes; hb_set_t *unicodes;

View File

@ -40,9 +40,8 @@ HB_BEGIN_DECLS
typedef struct hb_subset_input_t hb_subset_input_t; typedef struct hb_subset_input_t hb_subset_input_t;
/** /**
* TODO(garretrieger): update to match added values, and no hinting change.
* hb_subset_flags_t: * hb_subset_flags_t:
* @HB_SUBSET_FLAGS_NONE: bit set with no flags set. * @HB_SUBSET_FLAGS_DEFAULT: all flags at their default value.
* @HB_SUBSET_FLAGS_NO_HINTING: If set hinting instructions will be dropped in * @HB_SUBSET_FLAGS_NO_HINTING: If set hinting instructions will be dropped in
* the produced subset. Otherwise hinting instructions will be retained. * the produced subset. Otherwise hinting instructions will be retained.
* Defaults to true. * Defaults to true.
@ -69,26 +68,23 @@ typedef struct hb_subset_input_t hb_subset_input_t;
* retained. If unset then the set accessed by * retained. If unset then the set accessed by
* hb_subset_input_layout_features_set() will be used to determine the features * hb_subset_input_layout_features_set() will be used to determine the features
* to be retained. * to be retained.
* HB_SUBSET_FLAGS_ALL: bit set with all flags set.
* *
* List of boolean properties that can be configured on the subset input. * List of boolean properties that can be configured on the subset input.
* *
* Since: REPLACE * Since: REPLACE
**/ **/
typedef enum typedef enum { /*< flags >*/
{ HB_SUBSET_FLAGS_DEFAULT = 0x00000000u,
HB_SUBSET_FLAGS_NONE = 0, HB_SUBSET_FLAGS_NO_HINTING = 0x00000001u,
HB_SUBSET_FLAGS_NO_HINTING = 1, HB_SUBSET_FLAGS_RETAIN_GIDS = 0x00000002u,
HB_SUBSET_FLAGS_RETAIN_GIDS = 1 << 1, HB_SUBSET_FLAGS_DESUBROUTINIZE = 0x00000004u,
HB_SUBSET_FLAGS_DESUBROUTINIZE = 1 << 2, HB_SUBSET_FLAGS_NAME_LEGACY = 0x00000008u,
HB_SUBSET_FLAGS_NAME_LEGACY = 1 << 3, HB_SUBSET_FLAGS_SET_OVERLAPS_FLAG = 0x00000010u,
HB_SUBSET_FLAGS_SET_OVERLAPS_FLAG = 1 << 4, HB_SUBSET_FLAGS_PASSTHROUGH_UNRECOGNIZED = 0x00000020u,
HB_SUBSET_FLAGS_PASSTHROUGH_UNRECOGNIZED = 1 << 5, HB_SUBSET_FLAGS_NOTDEF_OUTLINE = 0x00000040u,
HB_SUBSET_FLAGS_NOTDEF_OUTLINE = 1 << 6, HB_SUBSET_FLAGS_GLYPH_NAMES = 0x00000080u,
HB_SUBSET_FLAGS_GLYPH_NAMES = 1 << 7, HB_SUBSET_FLAGS_NO_PRUNE_UNICODE_RANGES = 0x00000100u,
HB_SUBSET_FLAGS_NO_PRUNE_UNICODE_RANGES = 1 << 8, HB_SUBSET_FLAGS_RETAIN_ALL_FEATURES = 0x00000200u,
HB_SUBSET_FLAGS_RETAIN_ALL_FEATURES = 1 << 9,
HB_SUBSET_FLAGS_ALL = -1,
} hb_subset_flags_t; } hb_subset_flags_t;
HB_EXTERN hb_subset_input_t * HB_EXTERN hb_subset_input_t *
@ -137,8 +133,7 @@ hb_subset_input_get_flags (hb_subset_input_t *input);
HB_EXTERN void HB_EXTERN void
hb_subset_input_set_flags (hb_subset_input_t *input, hb_subset_input_set_flags (hb_subset_input_t *input,
hb_subset_flags_t mask, unsigned value);
hb_subset_flags_t value);
HB_EXTERN hb_face_t * HB_EXTERN hb_face_t *
hb_subset_or_fail (hb_face_t *source, const hb_subset_input_t *input); hb_subset_or_fail (hb_face_t *source, const hb_subset_input_t *input);

View File

@ -76,8 +76,7 @@ hb_subset_test_create_input_from_nameids (const hb_set_t *name_ids)
hb_set_add_range (name_langids, 0, 0x5FFF); hb_set_add_range (name_langids, 0, 0x5FFF);
hb_subset_input_set_flags (input, hb_subset_input_set_flags (input,
HB_SUBSET_FLAGS_NAME_LEGACY, HB_SUBSET_FLAGS_NAME_LEGACY);
HB_SUBSET_FLAGS_ALL);
return input; return input;
} }

View File

@ -80,7 +80,7 @@ test_subset_cff1_strip_hints (void)
hb_set_add (codepoints, 'a'); hb_set_add (codepoints, 'a');
hb_set_add (codepoints, 'c'); hb_set_add (codepoints, 'c');
input = hb_subset_test_create_input (codepoints); input = hb_subset_test_create_input (codepoints);
hb_subset_input_set_flags (input, HB_SUBSET_FLAGS_NO_HINTING, HB_SUBSET_FLAGS_ALL); hb_subset_input_set_flags (input, HB_SUBSET_FLAGS_NO_HINTING);
face_abc_subset = hb_subset_test_create_subset (face_abc, input); face_abc_subset = hb_subset_test_create_subset (face_abc, input);
hb_set_destroy (codepoints); hb_set_destroy (codepoints);
@ -103,7 +103,7 @@ test_subset_cff1_desubr (void)
hb_set_add (codepoints, 'a'); hb_set_add (codepoints, 'a');
hb_set_add (codepoints, 'c'); hb_set_add (codepoints, 'c');
input = hb_subset_test_create_input (codepoints); input = hb_subset_test_create_input (codepoints);
hb_subset_input_set_flags (input, HB_SUBSET_FLAGS_DESUBROUTINIZE, HB_SUBSET_FLAGS_ALL); hb_subset_input_set_flags (input, HB_SUBSET_FLAGS_DESUBROUTINIZE);
face_abc_subset = hb_subset_test_create_subset (face_abc, input); face_abc_subset = hb_subset_test_create_subset (face_abc, input);
hb_set_destroy (codepoints); hb_set_destroy (codepoints);
@ -127,8 +127,7 @@ test_subset_cff1_desubr_strip_hints (void)
hb_set_add (codepoints, 'c'); hb_set_add (codepoints, 'c');
input = hb_subset_test_create_input (codepoints); input = hb_subset_test_create_input (codepoints);
hb_subset_input_set_flags (input, hb_subset_input_set_flags (input,
HB_SUBSET_FLAGS_NO_HINTING | HB_SUBSET_FLAGS_DESUBROUTINIZE, HB_SUBSET_FLAGS_NO_HINTING | HB_SUBSET_FLAGS_DESUBROUTINIZE);
HB_SUBSET_FLAGS_ALL);
face_abc_subset = hb_subset_test_create_subset (face_abc, input); face_abc_subset = hb_subset_test_create_subset (face_abc, input);
hb_set_destroy (codepoints); hb_set_destroy (codepoints);
@ -171,7 +170,7 @@ test_subset_cff1_j_strip_hints (void)
hb_set_add (codepoints, 0x41); hb_set_add (codepoints, 0x41);
hb_set_add (codepoints, 0x4C2E); hb_set_add (codepoints, 0x4C2E);
input = hb_subset_test_create_input (codepoints); input = hb_subset_test_create_input (codepoints);
hb_subset_input_set_flags (input, HB_SUBSET_FLAGS_NO_HINTING, HB_SUBSET_FLAGS_ALL); hb_subset_input_set_flags (input, HB_SUBSET_FLAGS_NO_HINTING);
face_41_3041_4c2e_subset = hb_subset_test_create_subset (face_41_3041_4c2e, input); face_41_3041_4c2e_subset = hb_subset_test_create_subset (face_41_3041_4c2e, input);
hb_set_destroy (codepoints); hb_set_destroy (codepoints);
@ -194,7 +193,7 @@ test_subset_cff1_j_desubr (void)
hb_set_add (codepoints, 0x41); hb_set_add (codepoints, 0x41);
hb_set_add (codepoints, 0x4C2E); hb_set_add (codepoints, 0x4C2E);
input = hb_subset_test_create_input (codepoints); input = hb_subset_test_create_input (codepoints);
hb_subset_input_set_flags (input, HB_SUBSET_FLAGS_DESUBROUTINIZE, HB_SUBSET_FLAGS_ALL); hb_subset_input_set_flags (input, HB_SUBSET_FLAGS_DESUBROUTINIZE);
face_41_3041_4c2e_subset = hb_subset_test_create_subset (face_41_3041_4c2e, input); face_41_3041_4c2e_subset = hb_subset_test_create_subset (face_41_3041_4c2e, input);
hb_set_destroy (codepoints); hb_set_destroy (codepoints);
@ -218,8 +217,7 @@ test_subset_cff1_j_desubr_strip_hints (void)
hb_set_add (codepoints, 0x4C2E); hb_set_add (codepoints, 0x4C2E);
input = hb_subset_test_create_input (codepoints); input = hb_subset_test_create_input (codepoints);
hb_subset_input_set_flags (input, hb_subset_input_set_flags (input,
HB_SUBSET_FLAGS_NO_HINTING | HB_SUBSET_FLAGS_DESUBROUTINIZE, HB_SUBSET_FLAGS_NO_HINTING | HB_SUBSET_FLAGS_DESUBROUTINIZE);
HB_SUBSET_FLAGS_ALL);
face_41_3041_4c2e_subset = hb_subset_test_create_subset (face_41_3041_4c2e, input); face_41_3041_4c2e_subset = hb_subset_test_create_subset (face_41_3041_4c2e, input);
hb_set_destroy (codepoints); hb_set_destroy (codepoints);
@ -281,7 +279,7 @@ test_subset_cff1_dotsection (void)
hb_face_t *face_test; hb_face_t *face_test;
hb_set_add (codepoints, 0x69); /* i */ hb_set_add (codepoints, 0x69); /* i */
input = hb_subset_test_create_input (codepoints); input = hb_subset_test_create_input (codepoints);
hb_subset_input_set_flags (input, HB_SUBSET_FLAGS_NO_HINTING, HB_SUBSET_FLAGS_ALL); hb_subset_input_set_flags (input, HB_SUBSET_FLAGS_NO_HINTING);
face_test = hb_subset_test_create_subset (face, input); face_test = hb_subset_test_create_subset (face, input);
hb_set_destroy (codepoints); hb_set_destroy (codepoints);
@ -304,7 +302,7 @@ test_subset_cff1_retaingids (void)
hb_set_add (codepoints, 'a'); hb_set_add (codepoints, 'a');
hb_set_add (codepoints, 'c'); hb_set_add (codepoints, 'c');
input = hb_subset_test_create_input (codepoints); input = hb_subset_test_create_input (codepoints);
hb_subset_input_set_flags (input, HB_SUBSET_FLAGS_RETAIN_GIDS, HB_SUBSET_FLAGS_ALL); hb_subset_input_set_flags (input, HB_SUBSET_FLAGS_RETAIN_GIDS);
face_abc_subset = hb_subset_test_create_subset (face_abc, input); face_abc_subset = hb_subset_test_create_subset (face_abc, input);
hb_set_destroy (codepoints); hb_set_destroy (codepoints);
@ -327,7 +325,7 @@ test_subset_cff1_j_retaingids (void)
hb_set_add (codepoints, 0x41); hb_set_add (codepoints, 0x41);
hb_set_add (codepoints, 0x4C2E); hb_set_add (codepoints, 0x4C2E);
input = hb_subset_test_create_input (codepoints); input = hb_subset_test_create_input (codepoints);
hb_subset_input_set_flags (input, HB_SUBSET_FLAGS_RETAIN_GIDS, HB_SUBSET_FLAGS_ALL); hb_subset_input_set_flags (input, HB_SUBSET_FLAGS_RETAIN_GIDS);
face_41_3041_4c2e_subset = hb_subset_test_create_subset (face_41_3041_4c2e, input); face_41_3041_4c2e_subset = hb_subset_test_create_subset (face_41_3041_4c2e, input);
hb_set_destroy (codepoints); hb_set_destroy (codepoints);

View File

@ -80,7 +80,7 @@ test_subset_cff2_strip_hints (void)
hb_set_add (codepoints, 'a'); hb_set_add (codepoints, 'a');
hb_set_add (codepoints, 'c'); hb_set_add (codepoints, 'c');
input = hb_subset_test_create_input (codepoints); input = hb_subset_test_create_input (codepoints);
hb_subset_input_set_flags (input, HB_SUBSET_FLAGS_NO_HINTING, HB_SUBSET_FLAGS_ALL); hb_subset_input_set_flags (input, HB_SUBSET_FLAGS_NO_HINTING);
face_abc_subset = hb_subset_test_create_subset (face_abc, input); face_abc_subset = hb_subset_test_create_subset (face_abc, input);
hb_set_destroy (codepoints); hb_set_destroy (codepoints);
@ -103,7 +103,7 @@ test_subset_cff2_desubr (void)
hb_set_add (codepoints, 'a'); hb_set_add (codepoints, 'a');
hb_set_add (codepoints, 'c'); hb_set_add (codepoints, 'c');
input = hb_subset_test_create_input (codepoints); input = hb_subset_test_create_input (codepoints);
hb_subset_input_set_flags (input, HB_SUBSET_FLAGS_DESUBROUTINIZE, HB_SUBSET_FLAGS_ALL); hb_subset_input_set_flags (input, HB_SUBSET_FLAGS_DESUBROUTINIZE);
face_abc_subset = hb_subset_test_create_subset (face_abc, input); face_abc_subset = hb_subset_test_create_subset (face_abc, input);
hb_set_destroy (codepoints); hb_set_destroy (codepoints);
@ -127,8 +127,7 @@ test_subset_cff2_desubr_strip_hints (void)
hb_set_add (codepoints, 'c'); hb_set_add (codepoints, 'c');
input = hb_subset_test_create_input (codepoints); input = hb_subset_test_create_input (codepoints);
hb_subset_input_set_flags (input, hb_subset_input_set_flags (input,
HB_SUBSET_FLAGS_DESUBROUTINIZE | HB_SUBSET_FLAGS_NO_HINTING, HB_SUBSET_FLAGS_DESUBROUTINIZE | HB_SUBSET_FLAGS_NO_HINTING);
HB_SUBSET_FLAGS_ALL);
face_abc_subset = hb_subset_test_create_subset (face_abc, input); face_abc_subset = hb_subset_test_create_subset (face_abc, input);
hb_set_destroy (codepoints); hb_set_destroy (codepoints);
@ -151,7 +150,7 @@ test_subset_cff2_retaingids (void)
hb_set_add (codepoints, 'a'); hb_set_add (codepoints, 'a');
hb_set_add (codepoints, 'c'); hb_set_add (codepoints, 'c');
input = hb_subset_test_create_input (codepoints); input = hb_subset_test_create_input (codepoints);
hb_subset_input_set_flags (input, HB_SUBSET_FLAGS_RETAIN_GIDS, HB_SUBSET_FLAGS_ALL); hb_subset_input_set_flags (input, HB_SUBSET_FLAGS_RETAIN_GIDS);
face_abc_subset = hb_subset_test_create_subset (face_abc, input); face_abc_subset = hb_subset_test_create_subset (face_abc, input);
hb_set_destroy (codepoints); hb_set_destroy (codepoints);

View File

@ -92,7 +92,7 @@ test_subset_glyf_set_overlaps_flag (void)
hb_set_add (codepoints, 508); hb_set_add (codepoints, 508);
hb_subset_input_t* input = hb_subset_test_create_input (codepoints); hb_subset_input_t* input = hb_subset_test_create_input (codepoints);
hb_subset_input_set_flags (input, HB_SUBSET_FLAGS_SET_OVERLAPS_FLAG, HB_SUBSET_FLAGS_ALL); hb_subset_input_set_flags (input, HB_SUBSET_FLAGS_SET_OVERLAPS_FLAG);
face_abcAE_subset = hb_subset_test_create_subset (face_abcAE, input); face_abcAE_subset = hb_subset_test_create_subset (face_abcAE, input);
hb_set_destroy (codepoints); hb_set_destroy (codepoints);
@ -239,7 +239,7 @@ test_subset_glyf_strip_hints_simple (void)
hb_set_add (codepoints, 'a'); hb_set_add (codepoints, 'a');
hb_set_add (codepoints, 'c'); hb_set_add (codepoints, 'c');
input = hb_subset_test_create_input (codepoints); input = hb_subset_test_create_input (codepoints);
hb_subset_input_set_flags (input, HB_SUBSET_FLAGS_NO_HINTING, HB_SUBSET_FLAGS_ALL); hb_subset_input_set_flags (input, HB_SUBSET_FLAGS_NO_HINTING);
face_abc_subset = hb_subset_test_create_subset (face_abc, input); face_abc_subset = hb_subset_test_create_subset (face_abc, input);
hb_set_destroy (codepoints); hb_set_destroy (codepoints);
@ -263,7 +263,7 @@ test_subset_glyf_strip_hints_composite (void)
hb_face_t *face_generated_subset; hb_face_t *face_generated_subset;
hb_set_add (codepoints, 0x1fc); hb_set_add (codepoints, 0x1fc);
input = hb_subset_test_create_input (codepoints); input = hb_subset_test_create_input (codepoints);
hb_subset_input_set_flags (input, HB_SUBSET_FLAGS_NO_HINTING, HB_SUBSET_FLAGS_ALL); hb_subset_input_set_flags (input, HB_SUBSET_FLAGS_NO_HINTING);
face_generated_subset = hb_subset_test_create_subset (face_components, input); face_generated_subset = hb_subset_test_create_subset (face_components, input);
hb_set_destroy (codepoints); hb_set_destroy (codepoints);
@ -298,7 +298,7 @@ test_subset_glyf_strip_hints_invalid (void)
} }
input = hb_subset_test_create_input (codepoints); input = hb_subset_test_create_input (codepoints);
hb_subset_input_set_flags (input, HB_SUBSET_FLAGS_NO_HINTING, HB_SUBSET_FLAGS_ALL); hb_subset_input_set_flags (input, HB_SUBSET_FLAGS_NO_HINTING);
hb_set_destroy (codepoints); hb_set_destroy (codepoints);
face_subset = hb_subset_or_fail (face, input); face_subset = hb_subset_or_fail (face, input);
@ -320,7 +320,7 @@ test_subset_glyf_retain_gids (void)
hb_set_add (codepoints, 99); hb_set_add (codepoints, 99);
hb_subset_input_t *input = hb_subset_test_create_input (codepoints); hb_subset_input_t *input = hb_subset_test_create_input (codepoints);
hb_subset_input_set_flags (input, HB_SUBSET_FLAGS_RETAIN_GIDS, HB_SUBSET_FLAGS_ALL); hb_subset_input_set_flags (input, HB_SUBSET_FLAGS_RETAIN_GIDS);
face_abc_subset = hb_subset_test_create_subset (face_abc, input); face_abc_subset = hb_subset_test_create_subset (face_abc, input);
hb_set_destroy (codepoints); hb_set_destroy (codepoints);
@ -344,7 +344,7 @@ test_subset_glyf_retain_gids_truncates (void)
hb_set_add (codepoints, 97); hb_set_add (codepoints, 97);
hb_subset_input_t *input = hb_subset_test_create_input (codepoints); hb_subset_input_t *input = hb_subset_test_create_input (codepoints);
hb_subset_input_set_flags (input, HB_SUBSET_FLAGS_RETAIN_GIDS, HB_SUBSET_FLAGS_ALL); hb_subset_input_set_flags (input, HB_SUBSET_FLAGS_RETAIN_GIDS);
face_abc_subset = hb_subset_test_create_subset (face_abc, input); face_abc_subset = hb_subset_test_create_subset (face_abc, input);
hb_set_destroy (codepoints); hb_set_destroy (codepoints);

View File

@ -79,7 +79,7 @@ test_subset_gvar_retaingids (void)
hb_set_add (codepoints, 'a'); hb_set_add (codepoints, 'a');
hb_set_add (codepoints, 'c'); hb_set_add (codepoints, 'c');
hb_subset_input_t *input = hb_subset_test_create_input (codepoints); hb_subset_input_t *input = hb_subset_test_create_input (codepoints);
hb_subset_input_set_flags (input, HB_SUBSET_FLAGS_RETAIN_GIDS, HB_SUBSET_FLAGS_ALL); hb_subset_input_set_flags (input, HB_SUBSET_FLAGS_RETAIN_GIDS);
face_abc_subset = hb_subset_test_create_subset (face_abc, input); face_abc_subset = hb_subset_test_create_subset (face_abc, input);
hb_set_destroy (codepoints); hb_set_destroy (codepoints);

View File

@ -79,7 +79,7 @@ test_subset_map_HVAR_retaingids (void)
hb_set_add (codepoints, 'a'); hb_set_add (codepoints, 'a');
hb_set_add (codepoints, 'c'); hb_set_add (codepoints, 'c');
hb_subset_input_t *input = hb_subset_test_create_input (codepoints); hb_subset_input_t *input = hb_subset_test_create_input (codepoints);
hb_subset_input_set_flags (input, HB_SUBSET_FLAGS_RETAIN_GIDS, HB_SUBSET_FLAGS_ALL); hb_subset_input_set_flags (input, HB_SUBSET_FLAGS_RETAIN_GIDS);
face_abc_subset = hb_subset_test_create_subset (face_abc, input); face_abc_subset = hb_subset_test_create_subset (face_abc, input);
hb_set_destroy (codepoints); hb_set_destroy (codepoints);
@ -160,7 +160,7 @@ test_subset_identity_HVAR_retaingids (void)
hb_set_add (codepoints, 'a'); hb_set_add (codepoints, 'a');
hb_set_add (codepoints, 'c'); hb_set_add (codepoints, 'c');
hb_subset_input_t *input = hb_subset_test_create_input (codepoints); hb_subset_input_t *input = hb_subset_test_create_input (codepoints);
hb_subset_input_set_flags (input, HB_SUBSET_FLAGS_RETAIN_GIDS, HB_SUBSET_FLAGS_ALL); hb_subset_input_set_flags (input, HB_SUBSET_FLAGS_RETAIN_GIDS);
face_abc_subset = hb_subset_test_create_subset (face_abc, input); face_abc_subset = hb_subset_test_create_subset (face_abc, input);
hb_set_destroy (codepoints); hb_set_destroy (codepoints);

View File

@ -79,7 +79,7 @@ test_subset_VVAR_retaingids (void)
hb_set_add (codepoints, 'a'); hb_set_add (codepoints, 'a');
hb_set_add (codepoints, 'c'); hb_set_add (codepoints, 'c');
hb_subset_input_t *input = hb_subset_test_create_input (codepoints); hb_subset_input_t *input = hb_subset_test_create_input (codepoints);
hb_subset_input_set_flags (input, HB_SUBSET_FLAGS_RETAIN_GIDS, HB_SUBSET_FLAGS_ALL); hb_subset_input_set_flags (input, HB_SUBSET_FLAGS_RETAIN_GIDS);
face_abc_subset = hb_subset_test_create_subset (face_abc, input); face_abc_subset = hb_subset_test_create_subset (face_abc, input);
hb_set_destroy (codepoints); hb_set_destroy (codepoints);

View File

@ -98,13 +98,12 @@ test_subset_set_flags (void)
{ {
hb_subset_input_t *input = hb_subset_input_create_or_fail (); hb_subset_input_t *input = hb_subset_input_create_or_fail ();
g_assert (hb_subset_input_get_flags (input) == HB_SUBSET_FLAGS_NONE); g_assert (hb_subset_input_get_flags (input) == HB_SUBSET_FLAGS_DEFAULT);
hb_subset_input_set_flags (input, hb_subset_input_set_flags (input,
HB_SUBSET_FLAGS_NAME_LEGACY | HB_SUBSET_FLAGS_NAME_LEGACY |
HB_SUBSET_FLAGS_NOTDEF_OUTLINE | HB_SUBSET_FLAGS_NOTDEF_OUTLINE |
HB_SUBSET_FLAGS_GLYPH_NAMES, HB_SUBSET_FLAGS_GLYPH_NAMES);
HB_SUBSET_FLAGS_ALL);
g_assert (hb_subset_input_get_flags (input) == g_assert (hb_subset_input_get_flags (input) ==
(hb_subset_flags_t) ( (hb_subset_flags_t) (
@ -113,12 +112,6 @@ test_subset_set_flags (void)
HB_SUBSET_FLAGS_GLYPH_NAMES)); HB_SUBSET_FLAGS_GLYPH_NAMES));
hb_subset_input_set_flags (input, hb_subset_input_set_flags (input,
HB_SUBSET_FLAGS_NAME_LEGACY |
HB_SUBSET_FLAGS_NOTDEF_OUTLINE |
HB_SUBSET_FLAGS_GLYPH_NAMES |
HB_SUBSET_FLAGS_RETAIN_ALL_FEATURES,
HB_SUBSET_FLAGS_NAME_LEGACY | HB_SUBSET_FLAGS_NAME_LEGACY |
HB_SUBSET_FLAGS_NOTDEF_OUTLINE | HB_SUBSET_FLAGS_NOTDEF_OUTLINE |
HB_SUBSET_FLAGS_RETAIN_ALL_FEATURES); HB_SUBSET_FLAGS_RETAIN_ALL_FEATURES);

View File

@ -11,12 +11,12 @@ static void
trySubset (hb_face_t *face, trySubset (hb_face_t *face,
const hb_codepoint_t text[], const hb_codepoint_t text[],
int text_length, int text_length,
hb_subset_flags_t flag_bits) unsigned flag_bits)
{ {
hb_subset_input_t *input = hb_subset_input_create_or_fail (); hb_subset_input_t *input = hb_subset_input_create_or_fail ();
if (!input) return; if (!input) return;
hb_subset_input_set_flags (input, HB_SUBSET_FLAGS_ALL, flag_bits); hb_subset_input_set_flags (input, (hb_subset_flags_t) flag_bits);
hb_set_t *codepoints = hb_subset_input_unicode_set (input); hb_set_t *codepoints = hb_subset_input_unicode_set (input);
@ -56,7 +56,7 @@ extern "C" int LLVMFuzzerTestOneInput (const uint8_t *data, size_t size)
hb_face_collect_unicodes (face, output); hb_face_collect_unicodes (face, output);
hb_set_destroy (output); hb_set_destroy (output);
hb_subset_flags_t flags = HB_SUBSET_FLAGS_NONE; unsigned flags = HB_SUBSET_FLAGS_DEFAULT;
const hb_codepoint_t text[] = const hb_codepoint_t text[] =
{ {
'A', 'B', 'C', 'D', 'E', 'X', 'Y', 'Z', '1', '2', 'A', 'B', 'C', 'D', 'E', 'X', 'Y', 'Z', '1', '2',

View File

@ -709,7 +709,7 @@ struct subset_options_t : option_group_t
{ {
for (unsigned i = 0; i < sizeof(int) * 8; i++) for (unsigned i = 0; i < sizeof(int) * 8; i++)
{ {
if (1 << i == flag) if (1u << i == flag)
return &flags[i]; return &flags[i];
} }
return &flags[sizeof(int) * 8 - 1]; return &flags[sizeof(int) * 8 - 1];
@ -719,12 +719,13 @@ struct subset_options_t : option_group_t
hb_subset_input_t * get_input () hb_subset_input_t * get_input ()
{ {
hb_subset_flags_t flags_set = HB_SUBSET_FLAGS_DEFAULT;
for (unsigned i = 0; i < sizeof(int) * 8; i++) for (unsigned i = 0; i < sizeof(int) * 8; i++)
{ {
hb_subset_input_set_flags (input, if (flags[i])
(hb_subset_flags_t) (1 << i), flags_set = (hb_subset_flags_t) (flags_set | (1u << i));
flags[i] ? HB_SUBSET_FLAGS_ALL : HB_SUBSET_FLAGS_NONE);
} }
hb_subset_input_set_flags (input, flags_set);
return input; return input;
} }