Merge pull request #4027 from harfbuzz/plan-simplify

Plan simplify
This commit is contained in:
Behdad Esfahbod 2023-01-11 12:14:17 -07:00 committed by GitHub
commit 865d174706
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 130 additions and 183 deletions

View File

@ -339,7 +339,7 @@ struct ColorStop
TRACE_SUBSET (this);
auto *out = c->serializer->embed (*this);
if (unlikely (!out)) return_trace (false);
return_trace (c->serializer->check_assign (out->paletteIndex, c->plan->colr_palettes->get (paletteIndex),
return_trace (c->serializer->check_assign (out->paletteIndex, c->plan->colr_palettes.get (paletteIndex),
HB_SERIALIZE_ERROR_INT_OVERFLOW));
}
@ -550,7 +550,7 @@ struct PaintColrLayers
TRACE_SUBSET (this);
auto *out = c->serializer->embed (this);
if (unlikely (!out)) return_trace (false);
return_trace (c->serializer->check_assign (out->firstLayerIndex, c->plan->colrv1_layers->get (firstLayerIndex),
return_trace (c->serializer->check_assign (out->firstLayerIndex, c->plan->colrv1_layers.get (firstLayerIndex),
HB_SERIALIZE_ERROR_INT_OVERFLOW));
return_trace (true);
@ -581,7 +581,7 @@ struct PaintSolid
TRACE_SUBSET (this);
auto *out = c->serializer->embed (*this);
if (unlikely (!out)) return_trace (false);
return_trace (c->serializer->check_assign (out->paletteIndex, c->plan->colr_palettes->get (paletteIndex),
return_trace (c->serializer->check_assign (out->paletteIndex, c->plan->colr_palettes.get (paletteIndex),
HB_SERIALIZE_ERROR_INT_OVERFLOW));
}
@ -1456,7 +1456,7 @@ struct ClipList
if (unlikely (!c->serializer->extend_min (out))) return_trace (false);
if (!c->serializer->check_assign (out->format, format, HB_SERIALIZE_ERROR_INT_OVERFLOW)) return_trace (false);
const hb_set_t& glyphset = *c->plan->_glyphset_colred;
const hb_set_t& glyphset = c->plan->_glyphset_colred;
const hb_map_t &glyph_map = *c->plan->glyph_map;
hb_map_t new_gid_offset_map;
@ -1641,7 +1641,7 @@ struct BaseGlyphList : SortedArray32Of<BaseGlyphPaintRecord>
TRACE_SUBSET (this);
auto *out = c->serializer->start_embed (this);
if (unlikely (!c->serializer->extend_min (out))) return_trace (false);
const hb_set_t* glyphset = c->plan->_glyphset_colred;
const hb_set_t* glyphset = &c->plan->_glyphset_colred;
for (const auto& _ : as_array ())
{
@ -1882,7 +1882,7 @@ struct COLR
TRACE_SUBSET (this);
const hb_map_t &reverse_glyph_map = *c->plan->reverse_glyph_map;
const hb_set_t& glyphset = *c->plan->_glyphset_colred;
const hb_set_t& glyphset = c->plan->_glyphset_colred;
auto base_it =
+ hb_range (c->plan->num_output_glyphs ())
@ -1931,7 +1931,7 @@ struct COLR
if (unlikely (!c->plan->new_gid_for_old_gid (out_layers[i].glyphId, &new_gid)))
return hb_pair_t<bool, hb_vector_t<LayerRecord>> (false, out_layers);
out_layers[i].glyphId = new_gid;
out_layers[i].colorIdx = c->plan->colr_palettes->get (layers[i].colorIdx);
out_layers[i].colorIdx = c->plan->colr_palettes.get (layers[i].colorIdx);
}
return hb_pair_t<bool, hb_vector_t<LayerRecord>> (true, out_layers);

View File

@ -239,7 +239,7 @@ struct CPAL
TRACE_SUBSET (this);
if (!numPalettes) return_trace (false);
const hb_map_t *color_index_map = c->plan->colr_palettes;
const hb_map_t *color_index_map = &c->plan->colr_palettes;
if (color_index_map->is_empty ()) return_trace (false);
hb_set_t retained_color_indices;

View File

@ -51,9 +51,9 @@ struct AnchorFormat3
if (unlikely (!c->serializer->embed (yCoordinate))) return_trace (false);
unsigned x_varidx = xDeviceTable ? (this+xDeviceTable).get_variation_index () : HB_OT_LAYOUT_NO_VARIATIONS_INDEX;
if (c->plan->layout_variation_idx_delta_map->has (x_varidx))
if (c->plan->layout_variation_idx_delta_map.has (x_varidx))
{
int delta = hb_second (c->plan->layout_variation_idx_delta_map->get (x_varidx));
int delta = hb_second (c->plan->layout_variation_idx_delta_map.get (x_varidx));
if (delta != 0)
{
if (!c->serializer->check_assign (out->xCoordinate, xCoordinate + delta,
@ -63,9 +63,9 @@ struct AnchorFormat3
}
unsigned y_varidx = yDeviceTable ? (this+yDeviceTable).get_variation_index () : HB_OT_LAYOUT_NO_VARIATIONS_INDEX;
if (c->plan->layout_variation_idx_delta_map->has (y_varidx))
if (c->plan->layout_variation_idx_delta_map.has (y_varidx))
{
int delta = hb_second (c->plan->layout_variation_idx_delta_map->get (y_varidx));
int delta = hb_second (c->plan->layout_variation_idx_delta_map.get (y_varidx));
if (delta != 0)
{
if (!c->serializer->check_assign (out->yCoordinate, yCoordinate + delta,
@ -80,8 +80,8 @@ struct AnchorFormat3
if (!c->serializer->embed (xDeviceTable)) return_trace (false);
if (!c->serializer->embed (yDeviceTable)) return_trace (false);
out->xDeviceTable.serialize_copy (c->serializer, xDeviceTable, this, 0, hb_serialize_context_t::Head, c->plan->layout_variation_idx_delta_map);
out->yDeviceTable.serialize_copy (c->serializer, yDeviceTable, this, 0, hb_serialize_context_t::Head, c->plan->layout_variation_idx_delta_map);
out->xDeviceTable.serialize_copy (c->serializer, xDeviceTable, this, 0, hb_serialize_context_t::Head, &c->plan->layout_variation_idx_delta_map);
out->yDeviceTable.serialize_copy (c->serializer, yDeviceTable, this, 0, hb_serialize_context_t::Head, &c->plan->layout_variation_idx_delta_map);
return_trace (out);
}

View File

@ -298,8 +298,8 @@ struct PairPosFormat2_4
for (unsigned class2_idx : + hb_range ((unsigned) class2Count) | hb_filter (klass2_map))
{
unsigned idx = (class1_idx * (unsigned) class2Count + class2_idx) * (len1 + len2);
valueFormat1.copy_values (c->serializer, out->valueFormat1, this, &values[idx], c->plan->layout_variation_idx_delta_map);
valueFormat2.copy_values (c->serializer, out->valueFormat2, this, &values[idx + len1], c->plan->layout_variation_idx_delta_map);
valueFormat1.copy_values (c->serializer, out->valueFormat1, this, &values[idx], &c->plan->layout_variation_idx_delta_map);
valueFormat2.copy_values (c->serializer, out->valueFormat2, this, &values[idx + len1], &c->plan->layout_variation_idx_delta_map);
}
}

View File

@ -177,7 +177,7 @@ struct PairSet
newFormats,
len1,
&glyph_map,
c->plan->layout_variation_idx_delta_map
&c->plan->layout_variation_idx_delta_map
};
const PairValueRecord *record = &firstPairValueRecord;

View File

@ -144,7 +144,7 @@ struct SinglePosFormat1
;
bool ret = bool (it);
SinglePos_serialize (c->serializer, this, it, c->plan->layout_variation_idx_delta_map, c->plan->all_axes_pinned);
SinglePos_serialize (c->serializer, this, it, &c->plan->layout_variation_idx_delta_map, c->plan->all_axes_pinned);
return_trace (ret);
}
};

View File

@ -163,7 +163,7 @@ struct SinglePosFormat2
;
bool ret = bool (it);
SinglePos_serialize (c->serializer, this, it, c->plan->layout_variation_idx_delta_map, c->plan->all_axes_pinned);
SinglePos_serialize (c->serializer, this, it, &c->plan->layout_variation_idx_delta_map, c->plan->all_axes_pinned);
return_trace (ret);
}
};

View File

@ -1414,7 +1414,7 @@ struct CmapSubtable
switch (format) {
case 4: return u.format4.serialize (c, it);
case 12: return u.format12.serialize (c, it);
case 14: return u.format14.serialize (c, plan->unicodes, plan->glyphs_requested, plan->glyph_map, base);
case 14: return u.format14.serialize (c, plan->unicodes, &plan->glyphs_requested, plan->glyph_map, base);
default: return;
}
}

View File

@ -156,19 +156,19 @@ struct hb_subset_layout_context_t :
{
if (tag_ == HB_OT_TAG_GSUB)
{
lookup_index_map = c_->plan->gsub_lookups;
script_langsys_map = c_->plan->gsub_langsys;
feature_index_map = c_->plan->gsub_features;
feature_substitutes_map = c_->plan->gsub_feature_substitutes_map;
feature_record_cond_idx_map = c_->plan->user_axes_location->is_empty () ? nullptr : c_->plan->gsub_feature_record_cond_idx_map;
lookup_index_map = &c_->plan->gsub_lookups;
script_langsys_map = &c_->plan->gsub_langsys;
feature_index_map = &c_->plan->gsub_features;
feature_substitutes_map = &c_->plan->gsub_feature_substitutes_map;
feature_record_cond_idx_map = c_->plan->user_axes_location->is_empty () ? nullptr : &c_->plan->gsub_feature_record_cond_idx_map;
}
else
{
lookup_index_map = c_->plan->gpos_lookups;
script_langsys_map = c_->plan->gpos_langsys;
feature_index_map = c_->plan->gpos_features;
feature_substitutes_map = c_->plan->gpos_feature_substitutes_map;
feature_record_cond_idx_map = c_->plan->user_axes_location->is_empty () ? nullptr : c_->plan->gpos_feature_record_cond_idx_map;
lookup_index_map = &c_->plan->gpos_lookups;
script_langsys_map = &c_->plan->gpos_langsys;
feature_index_map = &c_->plan->gpos_features;
feature_substitutes_map = &c_->plan->gpos_feature_substitutes_map;
feature_record_cond_idx_map = c_->plan->user_axes_location->is_empty () ? nullptr : &c_->plan->gpos_feature_record_cond_idx_map;
}
}
@ -1145,7 +1145,7 @@ struct Script
{
TRACE_SUBSET (this);
if (!l->visitScript ()) return_trace (false);
if (tag && !c->plan->layout_scripts->has (*tag))
if (tag && !c->plan->layout_scripts.has (*tag))
return false;
auto *out = c->serializer->start_embed (*this);
@ -1532,7 +1532,7 @@ struct ClassDefFormat1_3
const Coverage* glyph_filter = nullptr) const
{
TRACE_SUBSET (this);
const hb_map_t &glyph_map = *c->plan->glyph_map_gsub;
const hb_map_t &glyph_map = c->plan->glyph_map_gsub;
hb_sorted_vector_t<hb_pair_t<hb_codepoint_t, hb_codepoint_t>> glyph_and_klass;
hb_set_t orig_klasses;
@ -1777,7 +1777,7 @@ struct ClassDefFormat2_4
const Coverage* glyph_filter = nullptr) const
{
TRACE_SUBSET (this);
const hb_map_t &glyph_map = *c->plan->glyph_map_gsub;
const hb_map_t &glyph_map = c->plan->glyph_map_gsub;
const hb_set_t &glyph_set = *c->plan->glyphset_gsub ();
hb_sorted_vector_t<hb_pair_t<hb_codepoint_t, hb_codepoint_t>> glyph_and_klass;

View File

@ -206,9 +206,9 @@ struct CaretValueFormat3
if (!c->serializer->embed (coordinate)) return_trace (false);
unsigned varidx = (this+deviceTable).get_variation_index ();
if (c->plan->layout_variation_idx_delta_map->has (varidx))
if (c->plan->layout_variation_idx_delta_map.has (varidx))
{
int delta = hb_second (c->plan->layout_variation_idx_delta_map->get (varidx));
int delta = hb_second (c->plan->layout_variation_idx_delta_map.get (varidx));
if (delta != 0)
{
if (!c->serializer->check_assign (out->coordinate, coordinate + delta, HB_SERIALIZE_ERROR_INT_OVERFLOW))
@ -223,7 +223,7 @@ struct CaretValueFormat3
return_trace (false);
return_trace (out->deviceTable.serialize_copy (c->serializer, deviceTable, this, c->serializer->to_bias (out),
hb_serialize_context_t::Head, c->plan->layout_variation_idx_delta_map));
hb_serialize_context_t::Head, &c->plan->layout_variation_idx_delta_map));
}
void collect_variation_indices (hb_collect_variation_indices_context_t *c) const

View File

@ -2223,7 +2223,7 @@ struct ContextFormat1_4
if (unlikely (!c->serializer->extend_min (out))) return_trace (false);
out->format = format;
const hb_map_t *lookup_map = c->table_tag == HB_OT_TAG_GSUB ? c->plan->gsub_lookups : c->plan->gpos_lookups;
const hb_map_t *lookup_map = c->table_tag == HB_OT_TAG_GSUB ? &c->plan->gsub_lookups : &c->plan->gpos_lookups;
hb_sorted_vector_t<hb_codepoint_t> new_coverage;
+ hb_zip (this+coverage, ruleSet)
| hb_filter (glyphset, hb_first)
@ -2460,7 +2460,7 @@ struct ContextFormat2_5
hb_set_t coverage_glyph_classes;
(this+classDef).intersected_classes (&retained_coverage_glyphs, &coverage_glyph_classes);
const hb_map_t *lookup_map = c->table_tag == HB_OT_TAG_GSUB ? c->plan->gsub_lookups : c->plan->gpos_lookups;
const hb_map_t *lookup_map = c->table_tag == HB_OT_TAG_GSUB ? &c->plan->gsub_lookups : &c->plan->gpos_lookups;
bool ret = true;
int non_zero_index = -1, index = 0;
auto snapshot = c->serializer->snapshot();
@ -2640,7 +2640,7 @@ struct ContextFormat3
}
const auto& lookupRecord = StructAfter<UnsizedArrayOf<LookupRecord>> (coverageZ.as_array (glyphCount));
const hb_map_t *lookup_map = c->table_tag == HB_OT_TAG_GSUB ? c->plan->gsub_lookups : c->plan->gpos_lookups;
const hb_map_t *lookup_map = c->table_tag == HB_OT_TAG_GSUB ? &c->plan->gsub_lookups : &c->plan->gpos_lookups;
unsigned count = serialize_lookuprecord_array (c->serializer, lookupRecord.as_array (lookupCount), lookup_map);
@ -3304,7 +3304,7 @@ struct ChainContextFormat1_4
if (unlikely (!c->serializer->extend_min (out))) return_trace (false);
out->format = format;
const hb_map_t *lookup_map = c->table_tag == HB_OT_TAG_GSUB ? c->plan->gsub_lookups : c->plan->gpos_lookups;
const hb_map_t *lookup_map = c->table_tag == HB_OT_TAG_GSUB ? &c->plan->gsub_lookups : &c->plan->gpos_lookups;
hb_sorted_vector_t<hb_codepoint_t> new_coverage;
+ hb_zip (this+coverage, ruleSet)
| hb_filter (glyphset, hb_first)
@ -3584,7 +3584,7 @@ struct ChainContextFormat2_5
int non_zero_index = -1, index = 0;
bool ret = true;
const hb_map_t *lookup_map = c->table_tag == HB_OT_TAG_GSUB ? c->plan->gsub_lookups : c->plan->gpos_lookups;
const hb_map_t *lookup_map = c->table_tag == HB_OT_TAG_GSUB ? &c->plan->gsub_lookups : &c->plan->gpos_lookups;
auto last_non_zero = c->serializer->snapshot ();
for (const auto& _ : + hb_enumerate (ruleSet)
| hb_filter (input_klass_map, hb_first))
@ -3826,7 +3826,7 @@ struct ChainContextFormat3
return_trace (false);
const auto &lookup = StructAfter<decltype (lookupX)> (lookahead);
const hb_map_t *lookup_map = c->table_tag == HB_OT_TAG_GSUB ? c->plan->gsub_lookups : c->plan->gpos_lookups;
const hb_map_t *lookup_map = c->table_tag == HB_OT_TAG_GSUB ? &c->plan->gsub_lookups : &c->plan->gpos_lookups;
HBUINT16 *lookupCount = c->serializer->copy<HBUINT16> (lookup.len);
if (!lookupCount) return_trace (false);

View File

@ -201,7 +201,7 @@ struct MathItalicsCorrectionInfo
bool subset (hb_subset_context_t *c) const
{
TRACE_SUBSET (this);
const hb_set_t &glyphset = *c->plan->_glyphset_mathed;
const hb_set_t &glyphset = c->plan->_glyphset_mathed;
const hb_map_t &glyph_map = *c->plan->glyph_map;
auto *out = c->serializer->start_embed (*this);
@ -254,7 +254,7 @@ struct MathTopAccentAttachment
bool subset (hb_subset_context_t *c) const
{
TRACE_SUBSET (this);
const hb_set_t &glyphset = *c->plan->_glyphset_mathed;
const hb_set_t &glyphset = c->plan->_glyphset_mathed;
const hb_map_t &glyph_map = *c->plan->glyph_map;
auto *out = c->serializer->start_embed (*this);
@ -486,7 +486,7 @@ struct MathKernInfo
bool subset (hb_subset_context_t *c) const
{
TRACE_SUBSET (this);
const hb_set_t &glyphset = *c->plan->_glyphset_mathed;
const hb_set_t &glyphset = c->plan->_glyphset_mathed;
const hb_map_t &glyph_map = *c->plan->glyph_map;
auto *out = c->serializer->start_embed (*this);
@ -567,7 +567,7 @@ struct MathGlyphInfo
out->mathItalicsCorrectionInfo.serialize_subset (c, mathItalicsCorrectionInfo, this);
out->mathTopAccentAttachment.serialize_subset (c, mathTopAccentAttachment, this);
const hb_set_t &glyphset = *c->plan->_glyphset_mathed;
const hb_set_t &glyphset = c->plan->_glyphset_mathed;
const hb_map_t &glyph_map = *c->plan->glyph_map;
auto it =
@ -938,7 +938,7 @@ struct MathVariants
bool subset (hb_subset_context_t *c) const
{
TRACE_SUBSET (this);
const hb_set_t &glyphset = *c->plan->_glyphset_mathed;
const hb_set_t &glyphset = c->plan->_glyphset_mathed;
const hb_map_t &glyph_map = *c->plan->glyph_map;
auto *out = c->serializer->start_embed (*this);

View File

@ -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;

View File

@ -49,43 +49,17 @@ struct hb_subset_plan_t
~hb_subset_plan_t()
{
hb_set_destroy (unicodes);
hb_set_destroy (name_ids);
hb_set_destroy (name_languages);
hb_set_destroy (layout_features);
hb_set_destroy (layout_scripts);
hb_set_destroy (glyphs_requested);
hb_set_destroy (drop_tables);
hb_set_destroy (no_subset_tables);
hb_face_destroy (source);
hb_face_destroy (dest);
hb_map_destroy (codepoint_to_glyph);
hb_map_destroy (glyph_map);
hb_map_destroy (reverse_glyph_map);
hb_map_destroy (glyph_map_gsub);
hb_set_destroy (_glyphset);
hb_set_destroy (_glyphset_gsub);
hb_set_destroy (_glyphset_mathed);
hb_set_destroy (_glyphset_colred);
hb_map_destroy (gsub_lookups);
hb_map_destroy (gpos_lookups);
hb_map_destroy (gsub_features);
hb_map_destroy (gpos_features);
hb_map_destroy (colrv1_layers);
hb_map_destroy (colr_palettes);
hb_map_destroy (axes_index_map);
hb_map_destroy (axes_old_index_tag_map);
hb_hashmap_destroy (gsub_langsys);
hb_hashmap_destroy (gpos_langsys);
hb_hashmap_destroy (gsub_feature_record_cond_idx_map);
hb_hashmap_destroy (gpos_feature_record_cond_idx_map);
hb_hashmap_destroy (gsub_feature_substitutes_map);
hb_hashmap_destroy (gpos_feature_substitutes_map);
hb_hashmap_destroy (axes_location);
hb_hashmap_destroy (sanitized_table_cache);
hb_hashmap_destroy (hmtx_map);
hb_hashmap_destroy (vmtx_map);
hb_hashmap_destroy (layout_variation_idx_delta_map);
#ifdef HB_EXPERIMENTAL_API
if (name_table_overrides)
@ -99,11 +73,7 @@ struct hb_subset_plan_t
if (inprogress_accelerator)
hb_subset_accelerator_t::destroy ((void*) inprogress_accelerator);
if (user_axes_location)
{
hb_object_destroy (user_axes_location);
hb_free (user_axes_location);
}
hb_hashmap_destroy (user_axes_location);
}
hb_object_header_t header;
@ -118,76 +88,76 @@ struct hb_subset_plan_t
hb_sorted_vector_t<hb_pair_t<hb_codepoint_t, hb_codepoint_t>> unicode_to_new_gid_list;
// name_ids we would like to retain
hb_set_t *name_ids;
hb_set_t name_ids;
// name_languages we would like to retain
hb_set_t *name_languages;
hb_set_t name_languages;
//layout features which will be preserved
hb_set_t *layout_features;
hb_set_t layout_features;
// layout scripts which will be preserved.
hb_set_t *layout_scripts;
hb_set_t layout_scripts;
//glyph ids requested to retain
hb_set_t *glyphs_requested;
hb_set_t glyphs_requested;
// Tables which should not be processed, just pass them through.
hb_set_t *no_subset_tables;
hb_set_t no_subset_tables;
// Tables which should be dropped.
hb_set_t *drop_tables;
hb_set_t drop_tables;
// The glyph subset
hb_map_t *codepoint_to_glyph;
hb_map_t *codepoint_to_glyph; // Needs to be heap-allocated
// Old -> New glyph id mapping
hb_map_t *glyph_map;
hb_map_t *reverse_glyph_map;
hb_map_t *glyph_map_gsub;
hb_map_t *glyph_map; // Needs to be heap-allocated
hb_map_t *reverse_glyph_map; // Needs to be heap-allocated
hb_map_t glyph_map_gsub;
// Plan is only good for a specific source/dest so keep them with it
hb_face_t *source;
hb_face_t *dest;
unsigned int _num_output_glyphs;
hb_set_t *_glyphset;
hb_set_t *_glyphset_gsub;
hb_set_t *_glyphset_mathed;
hb_set_t *_glyphset_colred;
hb_set_t _glyphset;
hb_set_t _glyphset_gsub;
hb_set_t _glyphset_mathed;
hb_set_t _glyphset_colred;
//active lookups we'd like to retain
hb_map_t *gsub_lookups;
hb_map_t *gpos_lookups;
hb_map_t gsub_lookups;
hb_map_t gpos_lookups;
//active langsys we'd like to retain
hb_hashmap_t<unsigned, hb::unique_ptr<hb_set_t>> *gsub_langsys;
hb_hashmap_t<unsigned, hb::unique_ptr<hb_set_t>> *gpos_langsys;
hb_hashmap_t<unsigned, hb::unique_ptr<hb_set_t>> gsub_langsys;
hb_hashmap_t<unsigned, hb::unique_ptr<hb_set_t>> gpos_langsys;
//active features after removing redundant langsys and prune_features
hb_map_t *gsub_features;
hb_map_t *gpos_features;
hb_map_t gsub_features;
hb_map_t gpos_features;
//active feature variation records/condition index with variations
hb_hashmap_t<unsigned, hb::shared_ptr<hb_set_t>> *gsub_feature_record_cond_idx_map;
hb_hashmap_t<unsigned, hb::shared_ptr<hb_set_t>> *gpos_feature_record_cond_idx_map;
hb_hashmap_t<unsigned, hb::shared_ptr<hb_set_t>> gsub_feature_record_cond_idx_map;
hb_hashmap_t<unsigned, hb::shared_ptr<hb_set_t>> gpos_feature_record_cond_idx_map;
//feature index-> address of substituation feature table mapping with
//variations
hb_hashmap_t<unsigned, const OT::Feature*> *gsub_feature_substitutes_map;
hb_hashmap_t<unsigned, const OT::Feature*> *gpos_feature_substitutes_map;
hb_hashmap_t<unsigned, const OT::Feature*> gsub_feature_substitutes_map;
hb_hashmap_t<unsigned, const OT::Feature*> gpos_feature_substitutes_map;
//active layers/palettes we'd like to retain
hb_map_t *colrv1_layers;
hb_map_t *colr_palettes;
hb_map_t colrv1_layers;
hb_map_t colr_palettes;
//Old layout item variation index -> (New varidx, delta) mapping
hb_hashmap_t<unsigned, hb_pair_t<unsigned, int>> *layout_variation_idx_delta_map;
hb_hashmap_t<unsigned, hb_pair_t<unsigned, int>> layout_variation_idx_delta_map;
//gdef varstore retained varidx mapping
hb_vector_t<hb_inc_bimap_t> gdef_varstore_inner_maps;
hb_hashmap_t<hb_tag_t, hb::unique_ptr<hb_blob_t>>* sanitized_table_cache;
hb_hashmap_t<hb_tag_t, hb::unique_ptr<hb_blob_t>> sanitized_table_cache;
//normalized axes location map
hb_hashmap_t<hb_tag_t, int> *axes_location;
hb_vector_t<int> normalized_coords;
@ -222,7 +192,7 @@ struct hb_subset_plan_t
{
hb_lock_t (accelerator ? &accelerator->sanitized_table_cache_lock : nullptr);
auto *cache = accelerator ? &accelerator->sanitized_table_cache : sanitized_table_cache;
auto *cache = accelerator ? &accelerator->sanitized_table_cache : &sanitized_table_cache;
if (cache
&& !cache->in_error ()
&& cache->has (+T::tableTag)) {
@ -254,7 +224,7 @@ struct hb_subset_plan_t
inline const hb_set_t *
glyphset () const
{
return _glyphset;
return &_glyphset;
}
/*
@ -263,7 +233,7 @@ struct hb_subset_plan_t
inline const hb_set_t *
glyphset_gsub () const
{
return _glyphset_gsub;
return &_glyphset_gsub;
}
/*
@ -281,7 +251,7 @@ struct hb_subset_plan_t
*/
inline bool is_empty_glyph (hb_codepoint_t gid) const
{
return !_glyphset->has (gid);
return !_glyphset.has (gid);
}
inline bool new_gid_for_codepoint (hb_codepoint_t codepoint,

View File

@ -168,11 +168,11 @@ _get_table_tags (const hb_subset_plan_t* plan,
hb_concat (
+ hb_array (known_tables)
| hb_filter ([&] (hb_tag_t tag) {
return !_table_is_empty (plan->source, tag) && !plan->no_subset_tables->has (tag);
return !_table_is_empty (plan->source, tag) && !plan->no_subset_tables.has (tag);
})
| hb_map ([] (hb_tag_t tag) -> hb_tag_t { return tag; }),
plan->no_subset_tables->iter ()
plan->no_subset_tables.iter ()
| hb_filter([&] (hb_tag_t tag) {
return !_table_is_empty (plan->source, tag);
}));
@ -355,7 +355,7 @@ _is_table_present (hb_face_t *source, hb_tag_t tag)
static bool
_should_drop_table (hb_subset_plan_t *plan, hb_tag_t tag)
{
if (plan->drop_tables->has (tag))
if (plan->drop_tables.has (tag))
return true;
switch (tag)
@ -424,7 +424,7 @@ _subset_table (hb_subset_plan_t *plan,
hb_vector_t<char> &buf,
hb_tag_t tag)
{
if (plan->no_subset_tables->has (tag)) {
if (plan->no_subset_tables.has (tag)) {
return _passthrough (plan, tag);
}