|
|
|
@ -139,13 +139,13 @@ static void _collect_layout_indices (hb_subset_plan_t *plan, |
|
|
|
|
hb_vector_t<hb_tag_t> features; |
|
|
|
|
if (!plan->check_success (features.resize (num_features))) return; |
|
|
|
|
table.get_feature_tags (0, &num_features, features.arrayZ); |
|
|
|
|
bool retain_all_features = !_filter_tag_list (&features, plan->layout_features); |
|
|
|
|
bool retain_all_features = !_filter_tag_list (&features, &plan->layout_features); |
|
|
|
|
|
|
|
|
|
unsigned num_scripts = table.get_script_count (); |
|
|
|
|
hb_vector_t<hb_tag_t> scripts; |
|
|
|
|
if (!plan->check_success (scripts.resize (num_scripts))) return; |
|
|
|
|
table.get_script_tags (0, &num_scripts, scripts.arrayZ); |
|
|
|
|
bool retain_all_scripts = !_filter_tag_list (&scripts, plan->layout_scripts); |
|
|
|
|
bool retain_all_scripts = !_filter_tag_list (&scripts, &plan->layout_scripts); |
|
|
|
|
|
|
|
|
|
if (!plan->check_success (!features.in_error ()) || !features |
|
|
|
|
|| !plan->check_success (!scripts.in_error ()) || !scripts) |
|
|
|
@ -301,7 +301,7 @@ _closure_glyphs_lookups_features (hb_subset_plan_t *plan, |
|
|
|
|
_GSUBGPOS_find_duplicate_features (*table, lookups, &feature_indices, feature_substitutes_map, &duplicate_feature_map); |
|
|
|
|
|
|
|
|
|
feature_indices.clear (); |
|
|
|
|
table->prune_langsys (&duplicate_feature_map, plan->layout_scripts, langsys_map, &feature_indices); |
|
|
|
|
table->prune_langsys (&duplicate_feature_map, &plan->layout_scripts, langsys_map, &feature_indices); |
|
|
|
|
_remap_indexes (&feature_indices, features); |
|
|
|
|
|
|
|
|
|
table.destroy (); |
|
|
|
@ -380,10 +380,10 @@ _collect_layout_variation_indices (hb_subset_plan_t* plan) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
OT::hb_collect_variation_indices_context_t c (&varidx_set, |
|
|
|
|
plan->layout_variation_idx_delta_map, |
|
|
|
|
&plan->layout_variation_idx_delta_map, |
|
|
|
|
font, var_store, |
|
|
|
|
plan->_glyphset_gsub, |
|
|
|
|
plan->gpos_lookups, |
|
|
|
|
&plan->_glyphset_gsub, |
|
|
|
|
&plan->gpos_lookups, |
|
|
|
|
store_cache); |
|
|
|
|
gdef->collect_variation_indices (&c); |
|
|
|
|
|
|
|
|
@ -393,7 +393,7 @@ _collect_layout_variation_indices (hb_subset_plan_t* plan) |
|
|
|
|
hb_font_destroy (font); |
|
|
|
|
var_store->destroy_cache (store_cache); |
|
|
|
|
|
|
|
|
|
gdef->remap_layout_variation_indices (&varidx_set, plan->layout_variation_idx_delta_map); |
|
|
|
|
gdef->remap_layout_variation_indices (&varidx_set, &plan->layout_variation_idx_delta_map); |
|
|
|
|
|
|
|
|
|
unsigned subtable_count = gdef->has_var_store () ? gdef->get_var_store ().get_sub_table_count () : 0; |
|
|
|
|
_generate_varstore_inner_maps (varidx_set, subtable_count, plan->gdef_varstore_inner_maps); |
|
|
|
@ -569,7 +569,7 @@ _populate_unicodes_to_retain (const hb_set_t *unicodes, |
|
|
|
|
{ |
|
|
|
|
if (gid >= plan->source->get_num_glyphs ()) |
|
|
|
|
break; |
|
|
|
|
plan->_glyphset_gsub->add (gid); |
|
|
|
|
plan->_glyphset_gsub.add (gid); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -577,7 +577,7 @@ _populate_unicodes_to_retain (const hb_set_t *unicodes, |
|
|
|
|
if (arr.length) |
|
|
|
|
{ |
|
|
|
|
plan->unicodes->add_sorted_array (&arr.arrayZ->first, arr.length, sizeof (*arr.arrayZ)); |
|
|
|
|
plan->_glyphset_gsub->add_array (&arr.arrayZ->second, arr.length, sizeof (*arr.arrayZ)); |
|
|
|
|
plan->_glyphset_gsub.add_array (&arr.arrayZ->second, arr.length, sizeof (*arr.arrayZ)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -619,71 +619,71 @@ _populate_gids_to_retain (hb_subset_plan_t* plan, |
|
|
|
|
OT::cff1::accelerator_t cff (plan->source); |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
plan->_glyphset_gsub->add (0); // Not-def
|
|
|
|
|
plan->_glyphset_gsub.add (0); // Not-def
|
|
|
|
|
|
|
|
|
|
_cmap_closure (plan->source, plan->unicodes, plan->_glyphset_gsub); |
|
|
|
|
_cmap_closure (plan->source, plan->unicodes, &plan->_glyphset_gsub); |
|
|
|
|
|
|
|
|
|
#ifndef HB_NO_SUBSET_LAYOUT |
|
|
|
|
if (!drop_tables->has (HB_OT_TAG_GSUB)) |
|
|
|
|
// closure all glyphs/lookups/features needed for GSUB substitutions.
|
|
|
|
|
_closure_glyphs_lookups_features<GSUB> ( |
|
|
|
|
plan, |
|
|
|
|
plan->_glyphset_gsub, |
|
|
|
|
plan->gsub_lookups, |
|
|
|
|
plan->gsub_features, |
|
|
|
|
plan->gsub_langsys, |
|
|
|
|
plan->gsub_feature_record_cond_idx_map, |
|
|
|
|
plan->gsub_feature_substitutes_map); |
|
|
|
|
&plan->_glyphset_gsub, |
|
|
|
|
&plan->gsub_lookups, |
|
|
|
|
&plan->gsub_features, |
|
|
|
|
&plan->gsub_langsys, |
|
|
|
|
&plan->gsub_feature_record_cond_idx_map, |
|
|
|
|
&plan->gsub_feature_substitutes_map); |
|
|
|
|
|
|
|
|
|
if (!drop_tables->has (HB_OT_TAG_GPOS)) |
|
|
|
|
_closure_glyphs_lookups_features<GPOS> ( |
|
|
|
|
plan, |
|
|
|
|
plan->_glyphset_gsub, |
|
|
|
|
plan->gpos_lookups, |
|
|
|
|
plan->gpos_features, |
|
|
|
|
plan->gpos_langsys, |
|
|
|
|
plan->gpos_feature_record_cond_idx_map, |
|
|
|
|
plan->gpos_feature_substitutes_map); |
|
|
|
|
&plan->_glyphset_gsub, |
|
|
|
|
&plan->gpos_lookups, |
|
|
|
|
&plan->gpos_features, |
|
|
|
|
&plan->gpos_langsys, |
|
|
|
|
&plan->gpos_feature_record_cond_idx_map, |
|
|
|
|
&plan->gpos_feature_substitutes_map); |
|
|
|
|
#endif |
|
|
|
|
_remove_invalid_gids (plan->_glyphset_gsub, plan->source->get_num_glyphs ()); |
|
|
|
|
_remove_invalid_gids (&plan->_glyphset_gsub, plan->source->get_num_glyphs ()); |
|
|
|
|
|
|
|
|
|
hb_set_set (plan->_glyphset_mathed, plan->_glyphset_gsub); |
|
|
|
|
plan->_glyphset_mathed = plan->_glyphset_gsub; |
|
|
|
|
if (!drop_tables->has (HB_OT_TAG_MATH)) |
|
|
|
|
{ |
|
|
|
|
_math_closure (plan, plan->_glyphset_mathed); |
|
|
|
|
_remove_invalid_gids (plan->_glyphset_mathed, plan->source->get_num_glyphs ()); |
|
|
|
|
_math_closure (plan, &plan->_glyphset_mathed); |
|
|
|
|
_remove_invalid_gids (&plan->_glyphset_mathed, plan->source->get_num_glyphs ()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
hb_set_t cur_glyphset = *plan->_glyphset_mathed; |
|
|
|
|
hb_set_t cur_glyphset = plan->_glyphset_mathed; |
|
|
|
|
if (!drop_tables->has (HB_OT_TAG_COLR)) |
|
|
|
|
{ |
|
|
|
|
_colr_closure (plan->source, plan->colrv1_layers, plan->colr_palettes, &cur_glyphset); |
|
|
|
|
_colr_closure (plan->source, &plan->colrv1_layers, &plan->colr_palettes, &cur_glyphset); |
|
|
|
|
_remove_invalid_gids (&cur_glyphset, plan->source->get_num_glyphs ()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
hb_set_set (plan->_glyphset_colred, &cur_glyphset); |
|
|
|
|
plan->_glyphset_colred = cur_glyphset; |
|
|
|
|
|
|
|
|
|
/* Populate a full set of glyphs to retain by adding all referenced
|
|
|
|
|
* composite glyphs. */ |
|
|
|
|
if (glyf.has_data ()) |
|
|
|
|
for (hb_codepoint_t gid : cur_glyphset) |
|
|
|
|
_glyf_add_gid_and_children (glyf, gid, plan->_glyphset, |
|
|
|
|
_glyf_add_gid_and_children (glyf, gid, &plan->_glyphset, |
|
|
|
|
cur_glyphset.get_population () * HB_COMPOSITE_OPERATIONS_PER_GLYPH); |
|
|
|
|
else |
|
|
|
|
plan->_glyphset->union_ (cur_glyphset); |
|
|
|
|
plan->_glyphset.union_ (cur_glyphset); |
|
|
|
|
#ifndef HB_NO_SUBSET_CFF |
|
|
|
|
if (!plan->accelerator || plan->accelerator->has_seac) |
|
|
|
|
{ |
|
|
|
|
bool has_seac = false; |
|
|
|
|
if (cff.is_valid ()) |
|
|
|
|
for (hb_codepoint_t gid : cur_glyphset) |
|
|
|
|
if (_add_cff_seac_components (cff, gid, plan->_glyphset)) |
|
|
|
|
if (_add_cff_seac_components (cff, gid, &plan->_glyphset)) |
|
|
|
|
has_seac = true; |
|
|
|
|
plan->has_seac = has_seac; |
|
|
|
|
} |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
_remove_invalid_gids (plan->_glyphset, plan->source->get_num_glyphs ()); |
|
|
|
|
_remove_invalid_gids (&plan->_glyphset, plan->source->get_num_glyphs ()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef HB_NO_VAR |
|
|
|
@ -842,45 +842,22 @@ hb_subset_plan_create_or_fail (hb_face_t *face, |
|
|
|
|
|
|
|
|
|
plan->unicode_to_new_gid_list.init (); |
|
|
|
|
|
|
|
|
|
plan->name_ids = hb_set_copy (input->sets.name_ids); |
|
|
|
|
plan->name_languages = hb_set_copy (input->sets.name_languages); |
|
|
|
|
plan->layout_features = hb_set_copy (input->sets.layout_features); |
|
|
|
|
plan->layout_scripts = hb_set_copy (input->sets.layout_scripts); |
|
|
|
|
plan->glyphs_requested = hb_set_copy (input->sets.glyphs); |
|
|
|
|
plan->drop_tables = hb_set_copy (input->sets.drop_tables); |
|
|
|
|
plan->no_subset_tables = hb_set_copy (input->sets.no_subset_tables); |
|
|
|
|
plan->name_ids = *input->sets.name_ids; |
|
|
|
|
plan->name_languages = *input->sets.name_languages; |
|
|
|
|
plan->layout_features = *input->sets.layout_features; |
|
|
|
|
plan->layout_scripts = *input->sets.layout_scripts; |
|
|
|
|
plan->glyphs_requested = *input->sets.glyphs; |
|
|
|
|
plan->drop_tables = *input->sets.drop_tables; |
|
|
|
|
plan->no_subset_tables = *input->sets.no_subset_tables; |
|
|
|
|
plan->source = hb_face_reference (face); |
|
|
|
|
plan->dest = hb_face_builder_create (); |
|
|
|
|
|
|
|
|
|
plan->_glyphset = hb_set_create (); |
|
|
|
|
plan->_glyphset_gsub = hb_set_create (); |
|
|
|
|
plan->_glyphset_mathed = hb_set_create (); |
|
|
|
|
plan->_glyphset_colred = hb_set_create (); |
|
|
|
|
plan->codepoint_to_glyph = hb_map_create (); |
|
|
|
|
plan->glyph_map = hb_map_create (); |
|
|
|
|
plan->reverse_glyph_map = hb_map_create (); |
|
|
|
|
plan->glyph_map_gsub = hb_map_create (); |
|
|
|
|
plan->gsub_lookups = hb_map_create (); |
|
|
|
|
plan->gpos_lookups = hb_map_create (); |
|
|
|
|
|
|
|
|
|
plan->check_success (plan->gsub_langsys = hb_hashmap_create<unsigned, hb::unique_ptr<hb_set_t>> ()); |
|
|
|
|
plan->check_success (plan->gpos_langsys = hb_hashmap_create<unsigned, hb::unique_ptr<hb_set_t>> ()); |
|
|
|
|
|
|
|
|
|
plan->gsub_features = hb_map_create (); |
|
|
|
|
plan->gpos_features = hb_map_create (); |
|
|
|
|
|
|
|
|
|
plan->check_success (plan->gsub_feature_record_cond_idx_map = hb_hashmap_create<unsigned, hb::shared_ptr<hb_set_t>> ()); |
|
|
|
|
plan->check_success (plan->gpos_feature_record_cond_idx_map = hb_hashmap_create<unsigned, hb::shared_ptr<hb_set_t>> ()); |
|
|
|
|
|
|
|
|
|
plan->check_success (plan->gsub_feature_substitutes_map = hb_hashmap_create<unsigned, const OT::Feature*> ()); |
|
|
|
|
plan->check_success (plan->gpos_feature_substitutes_map = hb_hashmap_create<unsigned, const OT::Feature*> ()); |
|
|
|
|
|
|
|
|
|
plan->colrv1_layers = hb_map_create (); |
|
|
|
|
plan->colr_palettes = hb_map_create (); |
|
|
|
|
plan->check_success (plan->layout_variation_idx_delta_map = hb_hashmap_create<unsigned, hb_pair_t<unsigned, int>> ()); |
|
|
|
|
plan->gdef_varstore_inner_maps.init (); |
|
|
|
|
|
|
|
|
|
plan->check_success (plan->sanitized_table_cache = hb_hashmap_create<hb_tag_t, hb::unique_ptr<hb_blob_t>> ()); |
|
|
|
|
plan->check_success (plan->axes_location = hb_hashmap_create<hb_tag_t, int> ()); |
|
|
|
|
plan->check_success (plan->user_axes_location = hb_hashmap_create<hb_tag_t, float> ()); |
|
|
|
|
if (plan->user_axes_location && input->axes_location) |
|
|
|
@ -934,15 +911,15 @@ hb_subset_plan_create_or_fail (hb_face_t *face, |
|
|
|
|
|
|
|
|
|
_create_old_gid_to_new_gid_map (face, |
|
|
|
|
input->flags & HB_SUBSET_FLAGS_RETAIN_GIDS, |
|
|
|
|
plan->_glyphset, |
|
|
|
|
&plan->_glyphset, |
|
|
|
|
plan->glyph_map, |
|
|
|
|
plan->reverse_glyph_map, |
|
|
|
|
&plan->_num_output_glyphs); |
|
|
|
|
|
|
|
|
|
_create_glyph_map_gsub ( |
|
|
|
|
plan->_glyphset_gsub, |
|
|
|
|
&plan->_glyphset_gsub, |
|
|
|
|
plan->glyph_map, |
|
|
|
|
plan->glyph_map_gsub); |
|
|
|
|
&plan->glyph_map_gsub); |
|
|
|
|
|
|
|
|
|
// Now that we have old to new gid map update the unicode to new gid list.
|
|
|
|
|
for (unsigned i = 0; i < plan->unicode_to_new_gid_list.length; i++) |
|
|
|
@ -952,7 +929,7 @@ hb_subset_plan_create_or_fail (hb_face_t *face, |
|
|
|
|
plan->glyph_map->get(plan->unicode_to_new_gid_list.arrayZ[i].second); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
_nameid_closure (face, plan->name_ids, plan->all_axes_pinned, plan->user_axes_location); |
|
|
|
|
_nameid_closure (face, &plan->name_ids, plan->all_axes_pinned, plan->user_axes_location); |
|
|
|
|
if (unlikely (plan->in_error ())) { |
|
|
|
|
hb_subset_plan_destroy (plan); |
|
|
|
|
return nullptr; |
|
|
|
|