[subset] support option "--notdef-outline"

This commit is contained in:
Qunxin Liu 2021-06-09 15:36:40 -07:00 committed by Behdad Esfahbod
parent 10ad185932
commit d07f789ae3
175 changed files with 42 additions and 11 deletions

View File

@ -209,6 +209,9 @@ struct glyf
if (!plan->old_gid_for_new_gid (new_gid, &subset_glyph.old_gid))
return subset_glyph;
if (new_gid == 0 && !plan->notdef_outline)
subset_glyph.source_glyph = Glyph ();
else
subset_glyph.source_glyph = glyf.glyph_for_gid (subset_glyph.old_gid, true);
if (plan->drop_hints) subset_glyph.drop_hints_bytes ();
else subset_glyph.dest_start = subset_glyph.source_glyph.get_bytes ();

View File

@ -419,7 +419,7 @@ struct gvar
out->glyphCount = num_glyphs;
unsigned int subset_data_size = 0;
for (hb_codepoint_t gid = 0; gid < num_glyphs; gid++)
for (hb_codepoint_t gid = c->plan->notdef_outline ? 0 : 1; gid < num_glyphs; gid++)
{
hb_codepoint_t old_gid;
if (!c->plan->old_gid_for_new_gid (gid, &old_gid)) continue;
@ -449,7 +449,7 @@ struct gvar
out->dataZ = subset_data - (char *) out;
unsigned int glyph_offset = 0;
for (hb_codepoint_t gid = 0; gid < num_glyphs; gid++)
for (hb_codepoint_t gid = c->plan->notdef_outline ? 0 : 1; gid < num_glyphs; gid++)
{
hb_codepoint_t old_gid;
hb_bytes_t var_data_bytes = c->plan->old_gid_for_new_gid (gid, &old_gid)

View File

@ -55,6 +55,7 @@ hb_subset_input_create_or_fail ()
input->retain_gids = false;
input->name_legacy = false;
input->overlaps_flag = false;
input->notdef_outline = false;
input->retain_all_layout_features = false;
hb_tag_t default_drop_tables[] = {
@ -349,3 +350,17 @@ hb_subset_input_get_overlaps_flag (hb_subset_input_t *subset_input)
{
return subset_input->overlaps_flag;
}
HB_EXTERN void
hb_subset_input_set_notdef_outline (hb_subset_input_t *subset_input,
hb_bool_t notdef_outline)
{
subset_input->notdef_outline = notdef_outline;
}
HB_EXTERN hb_bool_t
hb_subset_input_get_notdef_outline (hb_subset_input_t *subset_input)
{
return subset_input->notdef_outline;
}

View File

@ -45,12 +45,14 @@ struct hb_subset_input_t
hb_set_t *drop_tables;
hb_set_t *layout_features;
bool drop_hints;
bool desubroutinize;
bool retain_gids;
bool name_legacy;
bool overlaps_flag;
bool retain_all_layout_features;
//use hb_bool_t to be consistent with G option parser
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 retain_all_layout_features;
/* TODO
*
* features

View File

@ -401,6 +401,7 @@ hb_subset_plan_create (hb_face_t *face,
plan->retain_gids = input->retain_gids;
plan->name_legacy = input->name_legacy;
plan->overlaps_flag = input->overlaps_flag;
plan->notdef_outline = input->notdef_outline;
plan->retain_all_layout_features = input->retain_all_layout_features;
plan->unicodes = hb_set_create ();
plan->name_ids = hb_set_reference (input->name_ids);

View File

@ -45,6 +45,7 @@ struct hb_subset_plan_t
bool retain_gids : 1;
bool name_legacy : 1;
bool overlaps_flag : 1;
bool notdef_outline : 1;
bool retain_all_layout_features : 1;
// For each cp that we'd like to retain maps to the corresponding gid.

View File

@ -103,6 +103,13 @@ hb_subset_input_set_overlaps_flag (hb_subset_input_t *subset_input,
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_subset () */
HB_EXTERN hb_face_t *
hb_subset (hb_face_t *source, hb_subset_input_t *input);

Some files were not shown because too many files have changed in this diff Show More