[subset] convert subset input flags into bit flags.
Store the flags in a bit set. Updates the public api to work with the bit set directly.
This commit is contained in:
parent
a78eb43c79
commit
3d534b146c
|
@ -54,16 +54,8 @@ hb_subset_input_create_or_fail (void)
|
||||||
input->layout_features = hb_set_create ();
|
input->layout_features = hb_set_create ();
|
||||||
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->drop_hints = false;
|
|
||||||
input->desubroutinize = false;
|
input->flags = HB_SUBSET_FLAGS_NONE;
|
||||||
input->retain_gids = false;
|
|
||||||
input->name_legacy = false;
|
|
||||||
input->overlaps_flag = false;
|
|
||||||
input->notdef_outline = false;
|
|
||||||
input->glyph_names = false;
|
|
||||||
input->no_prune_unicode_ranges = false;
|
|
||||||
input->retain_all_layout_features = false;
|
|
||||||
input->passthrough_unrecognized = false;
|
|
||||||
|
|
||||||
hb_tag_t default_drop_tables[] = {
|
hb_tag_t default_drop_tables[] = {
|
||||||
// Layout disabled by default
|
// Layout disabled by default
|
||||||
|
@ -362,98 +354,39 @@ hb_subset_input_no_subset_tables_set (hb_subset_input_t *input)
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* hb_subset_input_get_flag:
|
* hb_subset_input_get_flags:
|
||||||
* @input: a #hb_subset_input_t object.
|
* @input: a #hb_subset_input_t object.
|
||||||
* @flag: which flag to check.
|
|
||||||
*
|
*
|
||||||
* Get the value of the specified flag.
|
* Return value: the subsetting flags bit array.
|
||||||
*
|
|
||||||
* Return value: value of the specified flag.
|
|
||||||
*
|
*
|
||||||
* Since: REPLACE
|
* Since: REPLACE
|
||||||
**/
|
**/
|
||||||
HB_EXTERN hb_bool_t
|
HB_EXTERN hb_subset_flags_t
|
||||||
hb_subset_input_get_flag (hb_subset_input_t *input,
|
hb_subset_input_get_flags (hb_subset_input_t *input)
|
||||||
hb_subset_flag_t flag)
|
|
||||||
{
|
{
|
||||||
switch (flag)
|
return input->flags;
|
||||||
{
|
|
||||||
case HB_SUBSET_FLAG_HINTING:
|
|
||||||
return !input->drop_hints;
|
|
||||||
case HB_SUBSET_FLAG_RETAIN_GIDS:
|
|
||||||
return input->retain_gids;
|
|
||||||
case HB_SUBSET_FLAG_DESUBROUTINIZE:
|
|
||||||
return input->desubroutinize;
|
|
||||||
case HB_SUBSET_FLAG_NAME_LEGACY:
|
|
||||||
return input->name_legacy;
|
|
||||||
case HB_SUBSET_FLAG_SET_OVERLAPS_FLAG:
|
|
||||||
return input->overlaps_flag;
|
|
||||||
case HB_SUBSET_FLAG_PASSTHROUGH_UNRECOGNIZED:
|
|
||||||
return input->passthrough_unrecognized;
|
|
||||||
case HB_SUBSET_FLAG_NOTDEF_OUTLINE:
|
|
||||||
return input->notdef_outline;
|
|
||||||
case HB_SUBSET_FLAG_GLYPH_NAMES:
|
|
||||||
return input->glyph_names;
|
|
||||||
case HB_SUBSET_FLAG_NO_PRUNE_UNICODE_RANGES:
|
|
||||||
return input->no_prune_unicode_ranges;
|
|
||||||
case HB_SUBSET_FLAG_RETAIN_ALL_FEATURES:
|
|
||||||
return input->retain_all_layout_features;
|
|
||||||
default:
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* hb_subset_input_set_flag:
|
* hb_subset_input_set_flags:
|
||||||
* @input: a #hb_subset_input_t object.
|
* @input: a #hb_subset_input_t object.
|
||||||
* @flag: which flag to set.
|
* @flag: which flag to set.
|
||||||
* @value: new value for the flag.
|
* @mask: bit mask which specifies which flags to change.
|
||||||
|
* @value: bit set of new values for those flags.
|
||||||
*
|
*
|
||||||
* Set the specified flag to @value.
|
* Updates the flags specified by the mask to the values in value.
|
||||||
*
|
*
|
||||||
* Since: REPLACE
|
* Since: REPLACE
|
||||||
**/
|
**/
|
||||||
HB_EXTERN void
|
HB_EXTERN void
|
||||||
hb_subset_input_set_flag (hb_subset_input_t *input,
|
hb_subset_input_set_flags (hb_subset_input_t *input,
|
||||||
hb_subset_flag_t flag,
|
hb_subset_flags_t mask,
|
||||||
hb_bool_t value)
|
hb_subset_flags_t value)
|
||||||
{
|
{
|
||||||
switch (flag)
|
// Set desired flags.
|
||||||
{
|
input->flags = (hb_subset_flags_t) (input->flags | (mask & value));
|
||||||
case HB_SUBSET_FLAG_HINTING:
|
// Clear desired flags.
|
||||||
input->drop_hints = !value;
|
input->flags = (hb_subset_flags_t) (input->flags & ~(mask & ~value));
|
||||||
break;
|
|
||||||
case HB_SUBSET_FLAG_RETAIN_GIDS:
|
|
||||||
input->retain_gids = value;
|
|
||||||
break;
|
|
||||||
case HB_SUBSET_FLAG_DESUBROUTINIZE:
|
|
||||||
input->desubroutinize = value;
|
|
||||||
break;
|
|
||||||
case HB_SUBSET_FLAG_NAME_LEGACY:
|
|
||||||
input->name_legacy = value;
|
|
||||||
break;
|
|
||||||
case HB_SUBSET_FLAG_SET_OVERLAPS_FLAG:
|
|
||||||
input->overlaps_flag = value;
|
|
||||||
break;
|
|
||||||
case HB_SUBSET_FLAG_PASSTHROUGH_UNRECOGNIZED:
|
|
||||||
input->passthrough_unrecognized = value;
|
|
||||||
break;
|
|
||||||
case HB_SUBSET_FLAG_NOTDEF_OUTLINE:
|
|
||||||
input->notdef_outline = value;
|
|
||||||
break;
|
|
||||||
case HB_SUBSET_FLAG_GLYPH_NAMES:
|
|
||||||
input->glyph_names = value;
|
|
||||||
break;
|
|
||||||
case HB_SUBSET_FLAG_NO_PRUNE_UNICODE_RANGES:
|
|
||||||
input->no_prune_unicode_ranges = value;
|
|
||||||
break;
|
|
||||||
case HB_SUBSET_FLAG_RETAIN_ALL_FEATURES:
|
|
||||||
input->retain_all_layout_features = value;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
// Do nothing.
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -46,17 +46,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;
|
||||||
|
|
||||||
//use hb_bool_t to be consistent with G option parser
|
hb_subset_flags_t flags;
|
||||||
hb_bool_t drop_hints;
|
|
||||||
hb_bool_t desubroutinize;
|
|
||||||
hb_bool_t retain_gids;
|
|
||||||
hb_bool_t name_legacy;
|
|
||||||
hb_bool_t overlaps_flag;
|
|
||||||
hb_bool_t notdef_outline;
|
|
||||||
hb_bool_t glyph_names;
|
|
||||||
hb_bool_t no_prune_unicode_ranges;
|
|
||||||
hb_bool_t retain_all_layout_features;
|
|
||||||
hb_bool_t passthrough_unrecognized;
|
|
||||||
|
|
||||||
/* TODO
|
/* TODO
|
||||||
*
|
*
|
||||||
|
|
|
@ -423,16 +423,16 @@ hb_subset_plan_create (hb_face_t *face,
|
||||||
return const_cast<hb_subset_plan_t *> (&Null (hb_subset_plan_t));
|
return const_cast<hb_subset_plan_t *> (&Null (hb_subset_plan_t));
|
||||||
|
|
||||||
plan->successful = true;
|
plan->successful = true;
|
||||||
plan->drop_hints = input->drop_hints;
|
plan->drop_hints = input->flags & HB_SUBSET_FLAGS_NO_HINTING;
|
||||||
plan->desubroutinize = input->desubroutinize;
|
plan->desubroutinize = input->flags & HB_SUBSET_FLAGS_DESUBROUTINIZE;
|
||||||
plan->retain_gids = input->retain_gids;
|
plan->retain_gids = input->flags & HB_SUBSET_FLAGS_RETAIN_GIDS;
|
||||||
plan->name_legacy = input->name_legacy;
|
plan->name_legacy = input->flags & HB_SUBSET_FLAGS_NAME_LEGACY;
|
||||||
plan->overlaps_flag = input->overlaps_flag;
|
plan->overlaps_flag = input->flags & HB_SUBSET_FLAGS_SET_OVERLAPS_FLAG;
|
||||||
plan->notdef_outline = input->notdef_outline;
|
plan->notdef_outline = input->flags & HB_SUBSET_FLAGS_NOTDEF_OUTLINE;
|
||||||
plan->glyph_names = input->glyph_names;
|
plan->glyph_names = input->flags & HB_SUBSET_FLAGS_GLYPH_NAMES;
|
||||||
plan->prune_unicode_ranges = !input->no_prune_unicode_ranges;
|
plan->prune_unicode_ranges = !(input->flags & HB_SUBSET_FLAGS_NO_PRUNE_UNICODE_RANGES);
|
||||||
plan->retain_all_layout_features = input->retain_all_layout_features;
|
plan->retain_all_layout_features = input->flags & HB_SUBSET_FLAGS_RETAIN_ALL_FEATURES;
|
||||||
plan->passthrough_unrecognized = input->passthrough_unrecognized;
|
plan->passthrough_unrecognized = input->flags & HB_SUBSET_FLAGS_PASSTHROUGH_UNRECOGNIZED;
|
||||||
plan->unicodes = hb_set_create ();
|
plan->unicodes = hb_set_create ();
|
||||||
plan->name_ids = hb_set_copy (input->name_ids);
|
plan->name_ids = hb_set_copy (input->name_ids);
|
||||||
_nameid_closure (face, plan->name_ids);
|
_nameid_closure (face, plan->name_ids);
|
||||||
|
@ -478,7 +478,7 @@ hb_subset_plan_create (hb_face_t *face,
|
||||||
!input->drop_tables->has (HB_OT_TAG_GDEF));
|
!input->drop_tables->has (HB_OT_TAG_GDEF));
|
||||||
|
|
||||||
_create_old_gid_to_new_gid_map (face,
|
_create_old_gid_to_new_gid_map (face,
|
||||||
input->retain_gids,
|
input->flags & HB_SUBSET_FLAGS_RETAIN_GIDS,
|
||||||
plan->_glyphset,
|
plan->_glyphset,
|
||||||
plan->glyph_map,
|
plan->glyph_map,
|
||||||
plan->reverse_glyph_map,
|
plan->reverse_glyph_map,
|
||||||
|
|
|
@ -40,33 +40,36 @@ HB_BEGIN_DECLS
|
||||||
typedef struct hb_subset_input_t hb_subset_input_t;
|
typedef struct hb_subset_input_t hb_subset_input_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* hb_subset_flag_t:
|
* TODO(garretrieger): update to match added values, and no hinting change.
|
||||||
* @HB_SUBSET_FLAG_HINTING: If set hinting instructions will be retained in
|
* hb_subset_flags_t:
|
||||||
* the produced subset. Otherwise hinting instructions will be dropped.
|
* @HB_SUBSET_FLAGS_NONE: bit set with no flags set.
|
||||||
|
* @HB_SUBSET_FLAGS_NO_HINTING: If set hinting instructions will be dropped in
|
||||||
|
* the produced subset. Otherwise hinting instructions will be retained.
|
||||||
* Defaults to true.
|
* Defaults to true.
|
||||||
* @HB_SUBSET_FLAG_RETAIN_GIDS: If set glyph indices will not be modified in
|
* @HB_SUBSET_FLAGS_RETAIN_GIDS: If set glyph indices will not be modified in
|
||||||
* the produced subset. If glyphs are dropped their indices will be retained
|
* the produced subset. If glyphs are dropped their indices will be retained
|
||||||
* as an empty glyph. Defaults to false.
|
* as an empty glyph. Defaults to false.
|
||||||
* @HB_SUBSET_FLAG_DESUBROUTINIZE: If set and subsetting a CFF font the
|
* @HB_SUBSET_FLAGS_DESUBROUTINIZE: If set and subsetting a CFF font the
|
||||||
* subsetter will attempt to remove subroutines from the CFF glyphs.
|
* subsetter will attempt to remove subroutines from the CFF glyphs.
|
||||||
* Defaults to false.
|
* Defaults to false.
|
||||||
* @HB_SUBSET_FLAG_NAME_LEGACY: If set non-unicode name records will be
|
* @HB_SUBSET_FLAGS_NAME_LEGACY: If set non-unicode name records will be
|
||||||
* retained in the subset. Defaults to false.
|
* retained in the subset. Defaults to false.
|
||||||
* @HB_SUBSET_FLAG_SET_OVERLAPS_FLAG: If set the subsetter will set the
|
* @HB_SUBSET_FLAGS_SET_OVERLAPS_FLAG: If set the subsetter will set the
|
||||||
* OVERLAP_SIMPLE flag on each simple glyph. Defaults to false.
|
* OVERLAP_SIMPLE flag on each simple glyph. Defaults to false.
|
||||||
* @HB_SUBSET_FLAG_PASSTHROUGH_UNRECOGNIZED: If set the subsetter will not
|
* @HB_SUBSET_FLAGS_PASSTHROUGH_UNRECOGNIZED: If set the subsetter will not
|
||||||
* drop unrecognized tables and instead pass them through untouched.
|
* drop unrecognized tables and instead pass them through untouched.
|
||||||
* Defaults to false.
|
* Defaults to false.
|
||||||
* @HB_SUBSET_FLAG_NOTDEF_OUTLINE: If set the notdef glyph outline will be
|
* @HB_SUBSET_FLAGS_NOTDEF_OUTLINE: If set the notdef glyph outline will be
|
||||||
* retained in the final subset. Defaults to false.
|
* retained in the final subset. Defaults to false.
|
||||||
* @HB_SUBSET_FLAG_GLYPH_NAMES: If set the PS glyph names will be retained
|
* @HB_SUBSET_FLAGS_GLYPH_NAMES: If set the PS glyph names will be retained
|
||||||
* in the final subset. Defaults to false.
|
* in the final subset. Defaults to false.
|
||||||
* @HB_SUBSET_FLAG_NO_PRUNE_UNICODE_RANGES: If set then the unicode ranges in
|
* @HB_SUBSET_FLAGS_NO_PRUNE_UNICODE_RANGES: If set then the unicode ranges in
|
||||||
* OS/2 will not be recalculated.
|
* OS/2 will not be recalculated.
|
||||||
* @HB_SUBSET_FLAG_RETAIN_ALL_FEATURES: If set all layout features will be
|
* @HB_SUBSET_FLAGS_RETAIN_ALL_FEATURES: If set all layout features will be
|
||||||
* 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.
|
||||||
*
|
*
|
||||||
|
@ -74,17 +77,19 @@ typedef struct hb_subset_input_t hb_subset_input_t;
|
||||||
**/
|
**/
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
HB_SUBSET_FLAG_HINTING = 0,
|
HB_SUBSET_FLAGS_NONE = 0,
|
||||||
HB_SUBSET_FLAG_RETAIN_GIDS,
|
HB_SUBSET_FLAGS_NO_HINTING = 1,
|
||||||
HB_SUBSET_FLAG_DESUBROUTINIZE,
|
HB_SUBSET_FLAGS_RETAIN_GIDS = 1 << 1,
|
||||||
HB_SUBSET_FLAG_NAME_LEGACY,
|
HB_SUBSET_FLAGS_DESUBROUTINIZE = 1 << 2,
|
||||||
HB_SUBSET_FLAG_SET_OVERLAPS_FLAG,
|
HB_SUBSET_FLAGS_NAME_LEGACY = 1 << 3,
|
||||||
HB_SUBSET_FLAG_PASSTHROUGH_UNRECOGNIZED,
|
HB_SUBSET_FLAGS_SET_OVERLAPS_FLAG = 1 << 4,
|
||||||
HB_SUBSET_FLAG_NOTDEF_OUTLINE,
|
HB_SUBSET_FLAGS_PASSTHROUGH_UNRECOGNIZED = 1 << 5,
|
||||||
HB_SUBSET_FLAG_GLYPH_NAMES,
|
HB_SUBSET_FLAGS_NOTDEF_OUTLINE = 1 << 6,
|
||||||
HB_SUBSET_FLAG_NO_PRUNE_UNICODE_RANGES,
|
HB_SUBSET_FLAGS_GLYPH_NAMES = 1 << 7,
|
||||||
HB_SUBSET_FLAG_RETAIN_ALL_FEATURES,
|
HB_SUBSET_FLAGS_NO_PRUNE_UNICODE_RANGES = 1 << 8,
|
||||||
} hb_subset_flag_t;
|
HB_SUBSET_FLAGS_RETAIN_ALL_FEATURES = 1 << 9,
|
||||||
|
HB_SUBSET_FLAGS_ALL = -1,
|
||||||
|
} hb_subset_flags_t;
|
||||||
|
|
||||||
HB_EXTERN hb_subset_input_t *
|
HB_EXTERN hb_subset_input_t *
|
||||||
hb_subset_input_create_or_fail (void);
|
hb_subset_input_create_or_fail (void);
|
||||||
|
@ -127,14 +132,13 @@ hb_subset_input_no_subset_tables_set (hb_subset_input_t *input);
|
||||||
HB_EXTERN hb_set_t *
|
HB_EXTERN hb_set_t *
|
||||||
hb_subset_input_drop_tables_set (hb_subset_input_t *input);
|
hb_subset_input_drop_tables_set (hb_subset_input_t *input);
|
||||||
|
|
||||||
HB_EXTERN hb_bool_t
|
HB_EXTERN hb_subset_flags_t
|
||||||
hb_subset_input_get_flag (hb_subset_input_t *input,
|
hb_subset_input_get_flags (hb_subset_input_t *input);
|
||||||
hb_subset_flag_t flag);
|
|
||||||
|
|
||||||
HB_EXTERN void
|
HB_EXTERN void
|
||||||
hb_subset_input_set_flag (hb_subset_input_t *input,
|
hb_subset_input_set_flags (hb_subset_input_t *input,
|
||||||
hb_subset_flag_t flag,
|
hb_subset_flags_t mask,
|
||||||
hb_bool_t 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);
|
||||||
|
|
|
@ -75,7 +75,9 @@ hb_subset_test_create_input_from_nameids (const hb_set_t *name_ids)
|
||||||
hb_set_t *name_langids = hb_subset_input_namelangid_set (input);
|
hb_set_t *name_langids = hb_subset_input_namelangid_set (input);
|
||||||
hb_set_add_range (name_langids, 0, 0x5FFF);
|
hb_set_add_range (name_langids, 0, 0x5FFF);
|
||||||
|
|
||||||
hb_subset_input_set_flag (input, HB_SUBSET_FLAG_NAME_LEGACY, true);
|
hb_subset_input_set_flags (input,
|
||||||
|
HB_SUBSET_FLAGS_NAME_LEGACY,
|
||||||
|
HB_SUBSET_FLAGS_ALL);
|
||||||
return input;
|
return input;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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_flag (input, HB_SUBSET_FLAG_HINTING, false);
|
hb_subset_input_set_flags (input, 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);
|
||||||
|
|
||||||
|
@ -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_flag (input, HB_SUBSET_FLAG_DESUBROUTINIZE, true);
|
hb_subset_input_set_flags (input, 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);
|
||||||
|
|
||||||
|
@ -126,8 +126,9 @@ test_subset_cff1_desubr_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_flag (input, HB_SUBSET_FLAG_HINTING, false);
|
hb_subset_input_set_flags (input,
|
||||||
hb_subset_input_set_flag (input, HB_SUBSET_FLAG_DESUBROUTINIZE, true);
|
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);
|
||||||
|
|
||||||
|
@ -170,7 +171,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_flag (input, HB_SUBSET_FLAG_HINTING, false);
|
hb_subset_input_set_flags (input, HB_SUBSET_FLAGS_NO_HINTING, 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);
|
||||||
|
|
||||||
|
@ -193,7 +194,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_flag (input, HB_SUBSET_FLAG_DESUBROUTINIZE, true);
|
hb_subset_input_set_flags (input, 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);
|
||||||
|
|
||||||
|
@ -216,8 +217,9 @@ test_subset_cff1_j_desubr_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_flag (input, HB_SUBSET_FLAG_HINTING, false);
|
hb_subset_input_set_flags (input,
|
||||||
hb_subset_input_set_flag (input, HB_SUBSET_FLAG_DESUBROUTINIZE, true);
|
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);
|
||||||
|
|
||||||
|
@ -279,7 +281,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_flag (input, HB_SUBSET_FLAG_HINTING, false);
|
hb_subset_input_set_flags (input, HB_SUBSET_FLAGS_NO_HINTING, HB_SUBSET_FLAGS_ALL);
|
||||||
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);
|
||||||
|
|
||||||
|
@ -302,7 +304,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_flag (input, HB_SUBSET_FLAG_RETAIN_GIDS, true);
|
hb_subset_input_set_flags (input, HB_SUBSET_FLAGS_RETAIN_GIDS, 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);
|
||||||
|
|
||||||
|
@ -325,7 +327,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_flag (input, HB_SUBSET_FLAG_RETAIN_GIDS, true);
|
hb_subset_input_set_flags (input, HB_SUBSET_FLAGS_RETAIN_GIDS, 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);
|
||||||
|
|
||||||
|
|
|
@ -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_flag (input, HB_SUBSET_FLAG_HINTING, false);
|
hb_subset_input_set_flags (input, 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);
|
||||||
|
|
||||||
|
@ -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_flag (input, HB_SUBSET_FLAG_DESUBROUTINIZE, true);
|
hb_subset_input_set_flags (input, 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);
|
||||||
|
|
||||||
|
@ -126,8 +126,9 @@ test_subset_cff2_desubr_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_flag (input, HB_SUBSET_FLAG_DESUBROUTINIZE, true);
|
hb_subset_input_set_flags (input,
|
||||||
hb_subset_input_set_flag (input, HB_SUBSET_FLAG_HINTING, false);
|
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);
|
||||||
|
|
||||||
|
@ -150,7 +151,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_flag (input, HB_SUBSET_FLAG_RETAIN_GIDS, true);
|
hb_subset_input_set_flags (input, HB_SUBSET_FLAGS_RETAIN_GIDS, 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);
|
||||||
|
|
||||||
|
|
|
@ -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_flag (input, HB_SUBSET_FLAG_SET_OVERLAPS_FLAG, true);
|
hb_subset_input_set_flags (input, HB_SUBSET_FLAGS_SET_OVERLAPS_FLAG, HB_SUBSET_FLAGS_ALL);
|
||||||
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_flag (input, HB_SUBSET_FLAG_HINTING, false);
|
hb_subset_input_set_flags (input, 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);
|
||||||
|
|
||||||
|
@ -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_flag (input, HB_SUBSET_FLAG_HINTING, false);
|
hb_subset_input_set_flags (input, HB_SUBSET_FLAGS_NO_HINTING, HB_SUBSET_FLAGS_ALL);
|
||||||
|
|
||||||
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_flag (input, HB_SUBSET_FLAG_HINTING, false);
|
hb_subset_input_set_flags (input, HB_SUBSET_FLAGS_NO_HINTING, HB_SUBSET_FLAGS_ALL);
|
||||||
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_flag (input, HB_SUBSET_FLAG_RETAIN_GIDS, true);
|
hb_subset_input_set_flags (input, HB_SUBSET_FLAGS_RETAIN_GIDS, 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);
|
||||||
|
|
||||||
|
@ -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_flag (input, HB_SUBSET_FLAG_RETAIN_GIDS, true);
|
hb_subset_input_set_flags (input, HB_SUBSET_FLAGS_RETAIN_GIDS, 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);
|
||||||
|
|
||||||
|
|
|
@ -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_flag (input, HB_SUBSET_FLAG_RETAIN_GIDS, true);
|
hb_subset_input_set_flags (input, HB_SUBSET_FLAGS_RETAIN_GIDS, 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);
|
||||||
|
|
||||||
|
|
|
@ -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_flag (input, HB_SUBSET_FLAG_RETAIN_GIDS, true);
|
hb_subset_input_set_flags (input, HB_SUBSET_FLAGS_RETAIN_GIDS, 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);
|
||||||
|
|
||||||
|
@ -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_flag (input, HB_SUBSET_FLAG_RETAIN_GIDS, true);
|
hb_subset_input_set_flags (input, HB_SUBSET_FLAGS_RETAIN_GIDS, 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);
|
||||||
|
|
||||||
|
|
|
@ -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_flag (input, HB_SUBSET_FLAG_RETAIN_GIDS, true);
|
hb_subset_input_set_flags (input, HB_SUBSET_FLAGS_RETAIN_GIDS, 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);
|
||||||
|
|
||||||
|
|
|
@ -93,6 +93,46 @@ test_subset_crash (void)
|
||||||
hb_face_destroy (face);
|
hb_face_destroy (face);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
test_subset_set_flags (void)
|
||||||
|
{
|
||||||
|
hb_subset_input_t *input = hb_subset_input_create_or_fail ();
|
||||||
|
|
||||||
|
g_assert (hb_subset_input_get_flags (input) == HB_SUBSET_FLAGS_NONE);
|
||||||
|
|
||||||
|
hb_subset_input_set_flags (input,
|
||||||
|
HB_SUBSET_FLAGS_NAME_LEGACY |
|
||||||
|
HB_SUBSET_FLAGS_NOTDEF_OUTLINE |
|
||||||
|
HB_SUBSET_FLAGS_GLYPH_NAMES,
|
||||||
|
HB_SUBSET_FLAGS_ALL);
|
||||||
|
|
||||||
|
g_assert (hb_subset_input_get_flags (input) ==
|
||||||
|
(hb_subset_flags_t) (
|
||||||
|
HB_SUBSET_FLAGS_NAME_LEGACY |
|
||||||
|
HB_SUBSET_FLAGS_NOTDEF_OUTLINE |
|
||||||
|
HB_SUBSET_FLAGS_GLYPH_NAMES));
|
||||||
|
|
||||||
|
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_NOTDEF_OUTLINE |
|
||||||
|
HB_SUBSET_FLAGS_RETAIN_ALL_FEATURES);
|
||||||
|
|
||||||
|
g_assert (hb_subset_input_get_flags (input) ==
|
||||||
|
(hb_subset_flags_t) (
|
||||||
|
HB_SUBSET_FLAGS_NAME_LEGACY |
|
||||||
|
HB_SUBSET_FLAGS_NOTDEF_OUTLINE |
|
||||||
|
HB_SUBSET_FLAGS_RETAIN_ALL_FEATURES));
|
||||||
|
|
||||||
|
|
||||||
|
hb_subset_input_destroy (input);
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
main (int argc, char **argv)
|
main (int argc, char **argv)
|
||||||
{
|
{
|
||||||
|
@ -101,6 +141,7 @@ main (int argc, char **argv)
|
||||||
hb_test_add (test_subset_32_tables);
|
hb_test_add (test_subset_32_tables);
|
||||||
hb_test_add (test_subset_no_inf_loop);
|
hb_test_add (test_subset_no_inf_loop);
|
||||||
hb_test_add (test_subset_crash);
|
hb_test_add (test_subset_crash);
|
||||||
|
hb_test_add (test_subset_set_flags);
|
||||||
|
|
||||||
return hb_test_run();
|
return hb_test_run();
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,22 +11,14 @@ 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,
|
||||||
bool drop_hints,
|
hb_subset_flags_t flag_bits)
|
||||||
bool drop_layout,
|
|
||||||
bool retain_gids)
|
|
||||||
{
|
{
|
||||||
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_flag (input, HB_SUBSET_FLAG_HINTING, !drop_hints);
|
|
||||||
hb_subset_input_set_flag (input, HB_SUBSET_FLAG_RETAIN_GIDS, retain_gids);
|
|
||||||
hb_set_t *codepoints = hb_subset_input_unicode_set (input);
|
|
||||||
|
|
||||||
if (!drop_layout)
|
hb_subset_input_set_flags (input, HB_SUBSET_FLAGS_ALL, flag_bits);
|
||||||
{
|
|
||||||
hb_set_del (hb_subset_input_drop_tables_set (input), HB_TAG ('G', 'S', 'U', 'B'));
|
hb_set_t *codepoints = hb_subset_input_unicode_set (input);
|
||||||
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'));
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < text_length; i++)
|
for (int i = 0; i < text_length; i++)
|
||||||
hb_set_add (codepoints, text[i]);
|
hb_set_add (codepoints, text[i]);
|
||||||
|
@ -51,19 +43,6 @@ trySubset (hb_face_t *face,
|
||||||
hb_subset_input_destroy (input);
|
hb_subset_input_destroy (input);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
trySubset (hb_face_t *face,
|
|
||||||
const hb_codepoint_t text[],
|
|
||||||
int text_length,
|
|
||||||
const uint8_t flags[1])
|
|
||||||
{
|
|
||||||
bool drop_hints = flags[0] & (1 << 0);
|
|
||||||
bool drop_layout = flags[0] & (1 << 1);
|
|
||||||
bool retain_gids = flags[0] & (1 << 2);
|
|
||||||
trySubset (face, text, text_length,
|
|
||||||
drop_hints, drop_layout, retain_gids);
|
|
||||||
}
|
|
||||||
|
|
||||||
extern "C" int LLVMFuzzerTestOneInput (const uint8_t *data, size_t size)
|
extern "C" int LLVMFuzzerTestOneInput (const uint8_t *data, size_t size)
|
||||||
{
|
{
|
||||||
alloc_state = size; /* see src/failing-alloc.c */
|
alloc_state = size; /* see src/failing-alloc.c */
|
||||||
|
@ -77,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);
|
||||||
|
|
||||||
uint8_t flags[1] = {0};
|
hb_subset_flags_t flags = HB_SUBSET_FLAGS_NONE;
|
||||||
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',
|
||||||
|
@ -92,7 +71,7 @@ extern "C" int LLVMFuzzerTestOneInput (const uint8_t *data, size_t size)
|
||||||
data + size - sizeof (text_from_data),
|
data + size - sizeof (text_from_data),
|
||||||
sizeof (text_from_data));
|
sizeof (text_from_data));
|
||||||
|
|
||||||
memcpy (flags,
|
memcpy (&flags,
|
||||||
data + size - sizeof (text_from_data) - sizeof (flags),
|
data + size - sizeof (text_from_data) - sizeof (flags),
|
||||||
sizeof (flags));
|
sizeof (flags));
|
||||||
unsigned int text_size = sizeof (text_from_data) / sizeof (hb_codepoint_t);
|
unsigned int text_size = sizeof (text_from_data) / sizeof (hb_codepoint_t);
|
||||||
|
|
|
@ -43,7 +43,7 @@ struct subset_consumer_t
|
||||||
const font_options_t *font_opts)
|
const font_options_t *font_opts)
|
||||||
{
|
{
|
||||||
font = hb_font_reference (font_opts->get_font ());
|
font = hb_font_reference (font_opts->get_font ());
|
||||||
input = hb_subset_input_reference (subset_options.input);
|
input = hb_subset_input_reference (subset_options.get_input ());
|
||||||
}
|
}
|
||||||
|
|
||||||
void consume_line (const char *text,
|
void consume_line (const char *text,
|
||||||
|
|
|
@ -217,9 +217,12 @@ parse_layout_features (const char *name,
|
||||||
if (0 == strcmp (arg, "*"))
|
if (0 == strcmp (arg, "*"))
|
||||||
{
|
{
|
||||||
if (last_name_char == '-')
|
if (last_name_char == '-')
|
||||||
|
{
|
||||||
hb_set_clear (layout_features);
|
hb_set_clear (layout_features);
|
||||||
else
|
*subset_opts->bool_for (HB_SUBSET_FLAGS_RETAIN_ALL_FEATURES) = false;
|
||||||
subset_opts->input->retain_all_layout_features = true;
|
} else {
|
||||||
|
*subset_opts->bool_for (HB_SUBSET_FLAGS_RETAIN_ALL_FEATURES) = true;
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -288,14 +291,14 @@ subset_options_t::add_options (option_parser_t *parser)
|
||||||
{
|
{
|
||||||
GOptionEntry entries[] =
|
GOptionEntry entries[] =
|
||||||
{
|
{
|
||||||
{"no-hinting", 0, 0, G_OPTION_ARG_NONE, &this->input->drop_hints, "Whether to drop hints", nullptr},
|
{"no-hinting", 0, 0, G_OPTION_ARG_NONE, this->bool_for (HB_SUBSET_FLAGS_NO_HINTING), "Whether to drop hints", nullptr},
|
||||||
{"retain-gids", 0, 0, G_OPTION_ARG_NONE, &this->input->retain_gids, "If set don't renumber glyph ids in the subset.", nullptr},
|
{"retain-gids", 0, 0, G_OPTION_ARG_NONE, this->bool_for (HB_SUBSET_FLAGS_RETAIN_GIDS), "If set don't renumber glyph ids in the subset.", nullptr},
|
||||||
{"gids", 0, 0, G_OPTION_ARG_CALLBACK, (gpointer) &parse_gids, "Specify glyph IDs or ranges to include in the subset", "list of comma/whitespace-separated int numbers or ranges"},
|
{"gids", 0, 0, G_OPTION_ARG_CALLBACK, (gpointer) &parse_gids, "Specify glyph IDs or ranges to include in the subset", "list of comma/whitespace-separated int numbers or ranges"},
|
||||||
{"desubroutinize", 0, 0, G_OPTION_ARG_NONE, &this->input->desubroutinize, "Remove CFF/CFF2 use of subroutines", nullptr},
|
{"desubroutinize", 0, 0, G_OPTION_ARG_NONE, this->bool_for (HB_SUBSET_FLAGS_DESUBROUTINIZE), "Remove CFF/CFF2 use of subroutines", nullptr},
|
||||||
{"name-IDs", 0, 0, G_OPTION_ARG_CALLBACK, (gpointer) &parse_nameids, "Subset specified nameids", "list of int numbers"},
|
{"name-IDs", 0, 0, G_OPTION_ARG_CALLBACK, (gpointer) &parse_nameids, "Subset specified nameids", "list of int numbers"},
|
||||||
{"name-IDs-", 0, 0, G_OPTION_ARG_CALLBACK, (gpointer) &parse_nameids, "Subset specified nameids", "list of int numbers"},
|
{"name-IDs-", 0, 0, G_OPTION_ARG_CALLBACK, (gpointer) &parse_nameids, "Subset specified nameids", "list of int numbers"},
|
||||||
{"name-IDs+", 0, 0, G_OPTION_ARG_CALLBACK, (gpointer) &parse_nameids, "Subset specified nameids", "list of int numbers"},
|
{"name-IDs+", 0, 0, G_OPTION_ARG_CALLBACK, (gpointer) &parse_nameids, "Subset specified nameids", "list of int numbers"},
|
||||||
{"name-legacy", 0, 0, G_OPTION_ARG_NONE, &this->input->name_legacy, "Keep legacy (non-Unicode) 'name' table entries", nullptr},
|
{"name-legacy", 0, 0, G_OPTION_ARG_NONE, this->bool_for (HB_SUBSET_FLAGS_NAME_LEGACY), "Keep legacy (non-Unicode) 'name' table entries", nullptr},
|
||||||
{"name-languages", 0, 0, G_OPTION_ARG_CALLBACK, (gpointer) &parse_name_languages, "Subset nameRecords with specified language IDs", "list of int numbers"},
|
{"name-languages", 0, 0, G_OPTION_ARG_CALLBACK, (gpointer) &parse_name_languages, "Subset nameRecords with specified language IDs", "list of int numbers"},
|
||||||
{"name-languages-", 0, 0, G_OPTION_ARG_CALLBACK, (gpointer) &parse_name_languages, "Subset nameRecords with specified language IDs", "list of int numbers"},
|
{"name-languages-", 0, 0, G_OPTION_ARG_CALLBACK, (gpointer) &parse_name_languages, "Subset nameRecords with specified language IDs", "list of int numbers"},
|
||||||
{"name-languages+", 0, 0, G_OPTION_ARG_CALLBACK, (gpointer) &parse_name_languages, "Subset nameRecords with specified language IDs", "list of int numbers"},
|
{"name-languages+", 0, 0, G_OPTION_ARG_CALLBACK, (gpointer) &parse_name_languages, "Subset nameRecords with specified language IDs", "list of int numbers"},
|
||||||
|
@ -308,11 +311,11 @@ subset_options_t::add_options (option_parser_t *parser)
|
||||||
{"num-iterations", 'n', 0, G_OPTION_ARG_INT,
|
{"num-iterations", 'n', 0, G_OPTION_ARG_INT,
|
||||||
&this->num_iterations,
|
&this->num_iterations,
|
||||||
"Run subsetter N times (default: 1)", "N"},
|
"Run subsetter N times (default: 1)", "N"},
|
||||||
{"set-overlaps-flag", 0, 0, G_OPTION_ARG_NONE, &this->input->overlaps_flag,
|
{"set-overlaps-flag", 0, 0, G_OPTION_ARG_NONE, this->bool_for (HB_SUBSET_FLAGS_SET_OVERLAPS_FLAG),
|
||||||
"Set the overlaps flag on each glyph.", nullptr},
|
"Set the overlaps flag on each glyph.", nullptr},
|
||||||
{"notdef-outline", 0, 0, G_OPTION_ARG_NONE, &this->input->notdef_outline, "Keep the outline of \'.notdef\' glyph", nullptr},
|
{"notdef-outline", 0, 0, G_OPTION_ARG_NONE, this->bool_for (HB_SUBSET_FLAGS_NOTDEF_OUTLINE), "Keep the outline of \'.notdef\' glyph", nullptr},
|
||||||
{"no-prune-unicode-ranges", 0, 0, G_OPTION_ARG_NONE, &this->input->no_prune_unicode_ranges, "Don't change the 'OS/2 ulUnicodeRange*' bits.", nullptr},
|
{"no-prune-unicode-ranges", 0, 0, G_OPTION_ARG_NONE, this->bool_for (HB_SUBSET_FLAGS_NO_PRUNE_UNICODE_RANGES), "Don't change the 'OS/2 ulUnicodeRange*' bits.", nullptr},
|
||||||
{"glyph-names", 0, 0, G_OPTION_ARG_NONE, &this->input->glyph_names, "Keep PS glyph names in TT-flavored fonts. ", nullptr},
|
{"glyph-names", 0, 0, G_OPTION_ARG_NONE, this->bool_for (HB_SUBSET_FLAGS_GLYPH_NAMES), "Keep PS glyph names in TT-flavored fonts. ", nullptr},
|
||||||
{nullptr}
|
{nullptr}
|
||||||
};
|
};
|
||||||
parser->add_group (entries,
|
parser->add_group (entries,
|
||||||
|
|
|
@ -705,7 +705,31 @@ struct subset_options_t : option_group_t
|
||||||
|
|
||||||
void add_options (option_parser_t *parser) override;
|
void add_options (option_parser_t *parser) override;
|
||||||
|
|
||||||
|
hb_bool_t* bool_for(hb_subset_flags_t flag)
|
||||||
|
{
|
||||||
|
for (unsigned i = 0; i < sizeof(int) * 8; i++)
|
||||||
|
{
|
||||||
|
if (1 << i == flag)
|
||||||
|
return &flags[i];
|
||||||
|
}
|
||||||
|
return &flags[sizeof(int) * 8 - 1];
|
||||||
|
}
|
||||||
|
|
||||||
unsigned num_iterations;
|
unsigned num_iterations;
|
||||||
|
|
||||||
|
hb_subset_input_t * get_input ()
|
||||||
|
{
|
||||||
|
for (unsigned i = 0; i < sizeof(int) * 8; i++)
|
||||||
|
{
|
||||||
|
hb_subset_input_set_flags (input,
|
||||||
|
(hb_subset_flags_t) (1 << i),
|
||||||
|
flags[i] ? HB_SUBSET_FLAGS_ALL : HB_SUBSET_FLAGS_NONE);
|
||||||
|
}
|
||||||
|
return input;
|
||||||
|
}
|
||||||
|
|
||||||
|
hb_bool_t flags[sizeof(int) * 8] = {0};
|
||||||
|
|
||||||
hb_subset_input_t *input;
|
hb_subset_input_t *input;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue