diff --git a/src/Makefile.sources b/src/Makefile.sources index fd7c3b55e..85537a58a 100644 --- a/src/Makefile.sources +++ b/src/Makefile.sources @@ -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 \ diff --git a/src/hb-subset-plan-member-list.hh b/src/hb-subset-plan-member-list.hh new file mode 100644 index 000000000..728c66e2f --- /dev/null +++ b/src/hb-subset-plan-member-list.hh @@ -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(>), 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(>), gsub_langsys) +HB_SUBSET_PLAN_MEMBER (hb_hashmap_t E(>), 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(>), gsub_feature_record_cond_idx_map) +HB_SUBSET_PLAN_MEMBER (hb_hashmap_t E(>), gpos_feature_record_cond_idx_map) + +//feature index-> address of substituation feature table mapping with +//variations +HB_SUBSET_PLAN_MEMBER (hb_hashmap_t E(), gsub_feature_substitutes_map) +HB_SUBSET_PLAN_MEMBER (hb_hashmap_t E(), 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()>), layout_variation_idx_delta_map) + +//gdef varstore retained varidx mapping +HB_SUBSET_PLAN_MEMBER (hb_vector_t, gdef_varstore_inner_maps) + +HB_SUBSET_PLAN_MEMBER (hb_hashmap_t E(>), sanitized_table_cache) + +//normalized axes location map +HB_SUBSET_PLAN_MEMBER (hb_hashmap_t E(), axes_location) +HB_SUBSET_PLAN_MEMBER (hb_vector_t, normalized_coords) + +//user specified axes location map +HB_SUBSET_PLAN_MEMBER (hb_hashmap_t E(), 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()>), hmtx_map) +//vmtx metrics map: new gid->(advance, lsb) +mutable HB_SUBSET_PLAN_MEMBER (hb_hashmap_t E()>), 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(), name_table_overrides) +#endif diff --git a/src/hb-subset-plan.hh b/src/hb-subset-plan.hh index e34eeb89a..19470ff83 100644 --- a/src/hb-subset-plan.hh +++ b/src/hb-subset-plan.hh @@ -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> 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> gsub_langsys; - hb_hashmap_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> gsub_feature_record_cond_idx_map; - hb_hashmap_t> gpos_feature_record_cond_idx_map; - - //feature index-> address of substituation feature table mapping with - //variations - hb_hashmap_t gsub_feature_substitutes_map; - hb_hashmap_t 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> layout_variation_idx_delta_map; - - //gdef varstore retained varidx mapping - hb_vector_t gdef_varstore_inner_maps; - - hb_hashmap_t> sanitized_table_cache; - //normalized axes location map - hb_hashmap_t axes_location; - hb_vector_t normalized_coords; - //user specified axes location map - hb_hashmap_t 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> hmtx_map; - //vmtx metrics map: new gid->(advance, lsb) - mutable hb_hashmap_t> 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 name_table_overrides; -#endif - const hb_subset_accelerator_t* accelerator; hb_subset_accelerator_t* inprogress_accelerator; diff --git a/src/meson.build b/src/meson.build index 30b99cf34..90735cb7e 100644 --- a/src/meson.build +++ b/src/meson.build @@ -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',