[subset-plan] Move all object members to a new file

To automatically check for their errors.
This commit is contained in:
Behdad Esfahbod 2023-05-05 15:49:38 -06:00
parent 71910fdf91
commit 5468b08c02
4 changed files with 131 additions and 85 deletions

View file

@ -362,6 +362,7 @@ HB_SUBSET_sources = \
hb-subset-accelerator.hh \
hb-subset-plan.cc \
hb-subset-plan.hh \
hb-subset-plan-member-list.hh \
hb-subset-repacker.cc \
hb-subset.cc \
hb-subset.hh \

View file

@ -0,0 +1,126 @@
/*
* Copyright © 2018 Google, Inc.
* Copyright © 2023 Behdad Esfahbod
*
* This is part of HarfBuzz, a text shaping library.
*
* Permission is hereby granted, without written agreement and without
* license or royalty fees, to use, copy, modify, and distribute this
* software and its documentation for any purpose, provided that the
* above copyright notice and the following two paragraphs appear in
* all copies of this software.
*
* IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
* DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
* ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
* IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
* DAMAGE.
*
* THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
* BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
* ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
* PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
*
* Google Author(s): Garret Rieger, Roderick Sheeter
*/
#ifndef HB_SUBSET_PLAN_MEMBER_LIST_HH
#define HB_SUBSET_PLAN_MEMBER_LIST_HH
#endif /* HB_SUBSET_PLAN_MEMBER_LIST_HH */ /* Dummy header guards */
#define E(x, y) x, y
// For each cp that we'd like to retain maps to the corresponding gid.
HB_SUBSET_PLAN_MEMBER (hb_set_t, unicodes)
HB_SUBSET_PLAN_MEMBER (hb_sorted_vector_t E(<hb_pair_t<hb_codepoint_t, hb_codepoint_t>>), unicode_to_new_gid_list)
// name_ids we would like to retain
HB_SUBSET_PLAN_MEMBER (hb_set_t, name_ids)
// name_languages we would like to retain
HB_SUBSET_PLAN_MEMBER (hb_set_t, name_languages)
//layout features which will be preserved
HB_SUBSET_PLAN_MEMBER (hb_set_t, layout_features)
// layout scripts which will be preserved.
HB_SUBSET_PLAN_MEMBER (hb_set_t, layout_scripts)
//glyph ids requested to retain
HB_SUBSET_PLAN_MEMBER (hb_set_t, glyphs_requested)
// Tables which should not be processed, just pass them through.
HB_SUBSET_PLAN_MEMBER (hb_set_t, no_subset_tables)
// Tables which should be dropped.
HB_SUBSET_PLAN_MEMBER (hb_set_t, drop_tables)
// Old -> New glyph id mapping
HB_SUBSET_PLAN_MEMBER (hb_map_t, glyph_map_gsub)
HB_SUBSET_PLAN_MEMBER (hb_set_t, _glyphset)
HB_SUBSET_PLAN_MEMBER (hb_set_t, _glyphset_gsub)
HB_SUBSET_PLAN_MEMBER (hb_set_t, _glyphset_mathed)
HB_SUBSET_PLAN_MEMBER (hb_set_t, _glyphset_colred)
//active lookups we'd like to retain
HB_SUBSET_PLAN_MEMBER (hb_map_t, gsub_lookups)
HB_SUBSET_PLAN_MEMBER (hb_map_t, gpos_lookups)
//active langsys we'd like to retain
HB_SUBSET_PLAN_MEMBER (hb_hashmap_t E(<unsigned, hb::unique_ptr<hb_set_t>>), gsub_langsys)
HB_SUBSET_PLAN_MEMBER (hb_hashmap_t E(<unsigned, hb::unique_ptr<hb_set_t>>), gpos_langsys)
//active features after removing redundant langsys and prune_features
HB_SUBSET_PLAN_MEMBER (hb_map_t, gsub_features)
HB_SUBSET_PLAN_MEMBER (hb_map_t, gpos_features)
//active feature variation records/condition index with variations
HB_SUBSET_PLAN_MEMBER (hb_hashmap_t E(<unsigned, hb::shared_ptr<hb_set_t>>), gsub_feature_record_cond_idx_map)
HB_SUBSET_PLAN_MEMBER (hb_hashmap_t E(<unsigned, hb::shared_ptr<hb_set_t>>), gpos_feature_record_cond_idx_map)
//feature index-> address of substituation feature table mapping with
//variations
HB_SUBSET_PLAN_MEMBER (hb_hashmap_t E(<unsigned, const OT::Feature*>), gsub_feature_substitutes_map)
HB_SUBSET_PLAN_MEMBER (hb_hashmap_t E(<unsigned, const OT::Feature*>), gpos_feature_substitutes_map)
//active layers/palettes we'd like to retain
HB_SUBSET_PLAN_MEMBER (hb_map_t, colrv1_layers)
HB_SUBSET_PLAN_MEMBER (hb_map_t, colr_palettes)
//Old layout item variation index -> (New varidx, delta) mapping
HB_SUBSET_PLAN_MEMBER (hb_hashmap_t E(<unsigned, hb_pair_t E(<unsigned, int>)>), layout_variation_idx_delta_map)
//gdef varstore retained varidx mapping
HB_SUBSET_PLAN_MEMBER (hb_vector_t<hb_inc_bimap_t>, gdef_varstore_inner_maps)
HB_SUBSET_PLAN_MEMBER (hb_hashmap_t E(<hb_tag_t, hb::unique_ptr<hb_blob_t>>), sanitized_table_cache)
//normalized axes location map
HB_SUBSET_PLAN_MEMBER (hb_hashmap_t E(<hb_tag_t, int>), axes_location)
HB_SUBSET_PLAN_MEMBER (hb_vector_t<int>, normalized_coords)
//user specified axes location map
HB_SUBSET_PLAN_MEMBER (hb_hashmap_t E(<hb_tag_t, float>), user_axes_location)
//retained old axis index -> new axis index mapping in fvar axis array
HB_SUBSET_PLAN_MEMBER (hb_map_t, axes_index_map)
//axis_index->axis_tag mapping in fvar axis array
HB_SUBSET_PLAN_MEMBER (hb_map_t, axes_old_index_tag_map)
//hmtx metrics map: new gid->(advance, lsb)
mutable HB_SUBSET_PLAN_MEMBER (hb_hashmap_t E(<hb_codepoint_t, hb_pair_t E(<unsigned, int>)>), hmtx_map)
//vmtx metrics map: new gid->(advance, lsb)
mutable HB_SUBSET_PLAN_MEMBER (hb_hashmap_t E(<hb_codepoint_t, hb_pair_t E(<unsigned, int>)>), vmtx_map)
//boundsWidth map: new gid->boundsWidth, boundWidth=xMax - xMin
mutable HB_SUBSET_PLAN_MEMBER (hb_map_t, bounds_width_map)
//boundsHeight map: new gid->boundsHeight, boundsHeight=yMax - yMin
mutable HB_SUBSET_PLAN_MEMBER (hb_map_t, bounds_height_map)
#ifdef HB_EXPERIMENTAL_API
// name table overrides map: hb_ot_name_record_ids_t-> name string new value or
// None to indicate should remove
HB_SUBSET_PLAN_MEMBER (hb_hashmap_t E(<hb_ot_name_record_ids_t, hb_bytes_t>), name_table_overrides)
#endif

View file

@ -97,112 +97,30 @@ struct hb_subset_plan_t
bool attach_accelerator_data = false;
bool force_long_loca = false;
// For each cp that we'd like to retain maps to the corresponding gid.
hb_set_t unicodes;
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;
// name_languages we would like to retain
hb_set_t name_languages;
//layout features which will be preserved
hb_set_t layout_features;
// layout scripts which will be preserved.
hb_set_t layout_scripts;
//glyph ids requested to retain
hb_set_t glyphs_requested;
// Tables which should not be processed, just pass them through.
hb_set_t no_subset_tables;
// Tables which should be dropped.
hb_set_t drop_tables;
// The glyph subset
hb_map_t *codepoint_to_glyph; // Needs to be heap-allocated
// Old -> New glyph id mapping
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;
//active lookups we'd like to retain
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;
//active features after removing redundant langsys and prune_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;
//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;
//active layers/palettes we'd like to retain
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;
//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;
//normalized axes location map
hb_hashmap_t<hb_tag_t, int> axes_location;
hb_vector_t<int> normalized_coords;
//user specified axes location map
hb_hashmap_t<hb_tag_t, float> user_axes_location;
//retained old axis index -> new axis index mapping in fvar axis array
hb_map_t axes_index_map;
//axis_index->axis_tag mapping in fvar axis array
hb_map_t axes_old_index_tag_map;
bool all_axes_pinned;
bool pinned_at_default;
bool has_seac;
//hmtx metrics map: new gid->(advance, lsb)
mutable hb_hashmap_t<hb_codepoint_t, hb_pair_t<unsigned, int>> hmtx_map;
//vmtx metrics map: new gid->(advance, lsb)
mutable hb_hashmap_t<hb_codepoint_t, hb_pair_t<unsigned, int>> vmtx_map;
//boundsWidth map: new gid->boundsWidth, boundWidth=xMax - xMin
mutable hb_map_t bounds_width_map;
//boundsHeight map: new gid->boundsHeight, boundsHeight=yMax - yMin
mutable hb_map_t bounds_height_map;
#define HB_SUBSET_PLAN_MEMBER(Type, Name) Type Name;
#include "hb-subset-plan-member-list.hh"
#undef HB_SUBSET_PLAN_MEMBER
//recalculated head/maxp table info after instancing
mutable head_maxp_info_t head_maxp_info;
#ifdef HB_EXPERIMENTAL_API
// name table overrides map: hb_ot_name_record_ids_t-> name string new value or
// None to indicate should remove
hb_hashmap_t<hb_ot_name_record_ids_t, hb_bytes_t> name_table_overrides;
#endif
const hb_subset_accelerator_t* accelerator;
hb_subset_accelerator_t* inprogress_accelerator;

View file

@ -361,6 +361,7 @@ hb_subset_sources = files(
'hb-subset-instancer-solver.cc',
'hb-subset-plan.cc',
'hb-subset-plan.hh',
'hb-subset-plan-member-list.hh',
'hb-subset-repacker.cc',
'graph/gsubgpos-context.cc',
'graph/gsubgpos-context.hh',