[subset] Add "--name-languages" and "--name-legacy" options
Make name table subsetting consistent with fontTools
This commit is contained in:
parent
b7762c7068
commit
36a5c042d7
@ -108,6 +108,15 @@ struct NameRecord
|
||||
return_trace (out);
|
||||
}
|
||||
|
||||
bool isUnicode () const
|
||||
{
|
||||
unsigned int p = platformID;
|
||||
unsigned int e = encodingID;
|
||||
|
||||
return (p == 0 ||
|
||||
(p == 3 && (e == 0 || e == 1 || e == 10)));
|
||||
}
|
||||
|
||||
bool sanitize (hb_sanitize_context_t *c, const void *base) const
|
||||
{
|
||||
TRACE_SANITIZE (this);
|
||||
@ -210,6 +219,8 @@ struct name
|
||||
auto it =
|
||||
+ nameRecordZ.as_array (count)
|
||||
| hb_filter (c->plan->name_ids, &NameRecord::nameID)
|
||||
| hb_filter (c->plan->name_languages, &NameRecord::languageID)
|
||||
| hb_filter ([&] (const NameRecord& namerecord) { return c->plan->name_legacy || namerecord.isUnicode (); })
|
||||
;
|
||||
|
||||
name_prime->serialize (c->serializer, it, hb_addressof (this + stringOffset));
|
||||
|
@ -46,10 +46,13 @@ hb_subset_input_create_or_fail ()
|
||||
input->glyphs = hb_set_create ();
|
||||
input->name_ids = hb_set_create ();
|
||||
hb_set_add_range (input->name_ids, 0, 6);
|
||||
input->name_languages = hb_set_create ();
|
||||
hb_set_add (input->name_languages, 0x0409);
|
||||
input->drop_tables = hb_set_create ();
|
||||
input->drop_hints = false;
|
||||
input->desubroutinize = false;
|
||||
input->retain_gids = false;
|
||||
input->name_legacy = false;
|
||||
|
||||
hb_tag_t default_drop_tables[] = {
|
||||
// Layout disabled by default
|
||||
@ -114,6 +117,7 @@ hb_subset_input_destroy (hb_subset_input_t *subset_input)
|
||||
hb_set_destroy (subset_input->unicodes);
|
||||
hb_set_destroy (subset_input->glyphs);
|
||||
hb_set_destroy (subset_input->name_ids);
|
||||
hb_set_destroy (subset_input->name_languages);
|
||||
hb_set_destroy (subset_input->drop_tables);
|
||||
|
||||
free (subset_input);
|
||||
@ -149,6 +153,12 @@ hb_subset_input_nameid_set (hb_subset_input_t *subset_input)
|
||||
return subset_input->name_ids;
|
||||
}
|
||||
|
||||
HB_EXTERN hb_set_t *
|
||||
hb_subset_input_namelangid_set (hb_subset_input_t *subset_input)
|
||||
{
|
||||
return subset_input->name_languages;
|
||||
}
|
||||
|
||||
HB_EXTERN hb_set_t *
|
||||
hb_subset_input_drop_tables_set (hb_subset_input_t *subset_input)
|
||||
{
|
||||
@ -204,3 +214,16 @@ hb_subset_input_get_retain_gids (hb_subset_input_t *subset_input)
|
||||
{
|
||||
return subset_input->retain_gids;
|
||||
}
|
||||
|
||||
HB_EXTERN void
|
||||
hb_subset_input_set_name_legacy (hb_subset_input_t *subset_input,
|
||||
hb_bool_t name_legacy)
|
||||
{
|
||||
subset_input->name_legacy = name_legacy;
|
||||
}
|
||||
|
||||
HB_EXTERN hb_bool_t
|
||||
hb_subset_input_get_name_legacy (hb_subset_input_t *subset_input)
|
||||
{
|
||||
return subset_input->name_legacy;
|
||||
}
|
||||
|
@ -41,11 +41,13 @@ struct hb_subset_input_t
|
||||
hb_set_t *unicodes;
|
||||
hb_set_t *glyphs;
|
||||
hb_set_t *name_ids;
|
||||
hb_set_t *name_languages;
|
||||
hb_set_t *drop_tables;
|
||||
|
||||
bool drop_hints;
|
||||
bool desubroutinize;
|
||||
bool retain_gids;
|
||||
bool name_legacy;
|
||||
/* TODO
|
||||
*
|
||||
* features
|
||||
|
@ -278,9 +278,11 @@ hb_subset_plan_create (hb_face_t *face,
|
||||
plan->drop_hints = input->drop_hints;
|
||||
plan->desubroutinize = input->desubroutinize;
|
||||
plan->retain_gids = input->retain_gids;
|
||||
plan->name_legacy = input->name_legacy;
|
||||
plan->unicodes = hb_set_create ();
|
||||
plan->name_ids = hb_set_reference (input->name_ids);
|
||||
_nameid_closure (face, plan->name_ids);
|
||||
plan->name_languages = hb_set_reference (input->name_languages);
|
||||
plan->drop_tables = hb_set_reference (input->drop_tables);
|
||||
plan->source = hb_face_reference (face);
|
||||
plan->dest = hb_face_builder_create ();
|
||||
@ -323,6 +325,7 @@ hb_subset_plan_destroy (hb_subset_plan_t *plan)
|
||||
|
||||
hb_set_destroy (plan->unicodes);
|
||||
hb_set_destroy (plan->name_ids);
|
||||
hb_set_destroy (plan->name_languages);
|
||||
hb_set_destroy (plan->drop_tables);
|
||||
hb_face_destroy (plan->source);
|
||||
hb_face_destroy (plan->dest);
|
||||
|
@ -42,6 +42,7 @@ struct hb_subset_plan_t
|
||||
bool drop_hints : 1;
|
||||
bool desubroutinize : 1;
|
||||
bool retain_gids : 1;
|
||||
bool name_legacy : 1;
|
||||
|
||||
// For each cp that we'd like to retain maps to the corresponding gid.
|
||||
hb_set_t *unicodes;
|
||||
@ -49,6 +50,9 @@ struct hb_subset_plan_t
|
||||
// name_ids we would like to retain
|
||||
hb_set_t *name_ids;
|
||||
|
||||
// name_languages we would like to retain
|
||||
hb_set_t *name_languages;
|
||||
|
||||
// Tables which should be dropped.
|
||||
hb_set_t *drop_tables;
|
||||
|
||||
|
@ -57,6 +57,9 @@ hb_subset_input_glyph_set (hb_subset_input_t *subset_input);
|
||||
HB_EXTERN hb_set_t *
|
||||
hb_subset_input_nameid_set (hb_subset_input_t *subset_input);
|
||||
|
||||
HB_EXTERN hb_set_t *
|
||||
hb_subset_input_namelangid_set (hb_subset_input_t *subset_input);
|
||||
|
||||
HB_EXTERN hb_set_t *
|
||||
hb_subset_input_drop_tables_set (hb_subset_input_t *subset_input);
|
||||
|
||||
@ -78,6 +81,12 @@ hb_subset_input_set_retain_gids (hb_subset_input_t *subset_input,
|
||||
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_subset () */
|
||||
HB_EXTERN hb_face_t *
|
||||
hb_subset (hb_face_t *source, hb_subset_input_t *input);
|
||||
|
@ -71,6 +71,11 @@ 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_set (input_name_ids, name_ids);
|
||||
|
||||
hb_set_t *name_langids = hb_subset_input_namelangid_set (input);
|
||||
hb_set_add_range (name_langids, 0, 0x5FFF);
|
||||
|
||||
hb_subset_input_set_name_legacy (input, true);
|
||||
return input;
|
||||
}
|
||||
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user