47 #ifndef HB_NO_SUBSET_CFF
54 if (
cff.get_seac_components (gid, &base_gid, &accent_gid))
56 gids_to_retain->
add (base_gid);
57 gids_to_retain->
add (accent_gid);
63 _remap_palette_indexes (
const hb_set_t *palette_indexes,
67 for (
unsigned palette_index : palette_indexes->
iter ())
69 if (palette_index == 0xFFFF)
71 mapping->set (palette_index, palette_index);
74 mapping->set (palette_index, new_idx);
80 _remap_indexes (
const hb_set_t *indexes,
85 for (
auto _ : + hb_zip (indexes->
iter (), hb_range (
count)))
90 #ifndef HB_NO_SUBSET_LAYOUT
97 const hb_set_t *layout_features_to_retain,
102 if (!features.
alloc (
table.get_feature_count () + 1))
106 bool retain_all_features =
true;
107 for (
unsigned i = 0;
i <
table.get_feature_count ();
i++)
111 if (!layout_features_to_retain->
has (
tag))
113 retain_all_features =
false;
117 if (visited_features.
has (
tag))
121 visited_features.
add (
tag);
130 if (retain_all_features)
133 layout_collect_func (
face,
142 layout_collect_func (
face,
150 template <
typename T>
154 const hb_set_t *layout_features_to_retain,
162 _collect_layout_indices<T> (
face,
164 layout_features_to_retain,
175 _remap_indexes (&lookup_indices, lookups);
179 _collect_layout_indices<T> (
face,
181 layout_features_to_retain,
185 table->prune_features (lookups, &feature_indices);
187 table->find_duplicate_features (lookups, &feature_indices, &duplicate_feature_map);
189 feature_indices.
clear ();
190 table->prune_langsys (&duplicate_feature_map, langsys_map, &feature_indices);
191 _remap_indexes (&feature_indices, features);
209 if (!gdef->has_data ())
216 gdef->collect_variation_indices (&
c);
219 gpos->collect_variation_indices (&
c);
221 gdef->remap_layout_variation_indices (layout_variation_indices, layout_variation_idx_map);
234 cmap.table->closure_glyphs (unicodes, glyphset);
243 if (!colr.is_valid ())
return;
245 unsigned iteration_count = 0;
246 hb_set_t palette_indices, layer_indices;
253 colr.closure_glyphs (gid, &glyphset_colrv0);
255 glyphs_colred->
union_ (glyphset_colrv0);
258 colr.closure_forV1 (glyphs_colred, &layer_indices, &palette_indices);
262 colr.closure_V0palette_indices (glyphs_colred, &palette_indices);
263 _remap_indexes (&layer_indices, layers_map);
264 _remap_palette_indexes (&palette_indices, palettes_map);
272 if (math->has_data ())
273 math->closure_glyphs (glyphset);
279 _remove_invalid_gids (
hb_set_t *glyphs,
280 unsigned int num_glyphs)
283 while (glyphs->
next (&gid))
285 if (gid >= num_glyphs)
291 _populate_unicodes_to_retain (
const hb_set_t *unicodes,
297 constexpr
static const int size_threshold = 4096;
306 if (!cmap.get_nominal_glyph (cp, &gid))
308 DEBUG_MSG(SUBSET,
nullptr,
"Drop U+%04X; no gid", cp);
321 + unicode_glyphid_map.
iter ())
323 if (!unicodes->has (cp_gid.first) && !glyphs->
has (cp_gid.second))
347 bool close_over_gsub,
348 bool close_over_gpos,
349 bool close_over_gdef)
352 #ifndef HB_NO_SUBSET_CFF
360 #ifndef HB_NO_SUBSET_LAYOUT
363 _closure_glyphs_lookups_features<GSUB> (
372 _closure_glyphs_lookups_features<OT::GPOS> (
395 glyf.add_gid_and_children (gid, plan->
_glyphset);
396 #ifndef HB_NO_SUBSET_CFF
407 _collect_layout_variation_indices (plan->
source,
421 unsigned int *num_glyphs )
426 | hb_sink (reverse_glyph_map)
430 + hb_iter (all_gids_to_retain)
434 | hb_sink (reverse_glyph_map)
438 + hb_iter (all_gids_to_retain)
439 | hb_reduce (hb_max, 0
u)
441 *num_glyphs = max_glyph + 1;
444 + reverse_glyph_map->
iter ()
446 | hb_sink (glyph_map)
455 face->table.STAT->collect_name_ids (nameids);
458 face->table.fvar->collect_name_ids (nameids);
482 if (
unlikely (!(plan = hb_object_create<hb_subset_plan_t> ())))
525 _populate_unicodes_to_retain (
input->sets.unicodes,
input->sets.glyphs, plan);
527 _populate_gids_to_retain (plan,
532 _create_old_gid_to_new_gid_map (
face,
558 if (!hb_object_destroy (plan))
return;
675 return hb_object_reference (plan);
699 return hb_object_set_user_data (plan,
key,
data,
destroy, replace);
718 return hb_object_get_user_data (plan,
key);
small capitals from c petite p scientific f u
small capitals from c petite p scientific i
[1]
#define DEBUG_MSG(WHAT, OBJ,...)
hb_face_t * hb_face_builder_create()
void hb_face_destroy(hb_face_t *face)
hb_face_t * hb_face_reference(hb_face_t *face)
auto it hb_map(hb_second)) template< typename Type > inline hb_array_t< Type > operator()(hb_array_t< Type > array
hb_map_t * hb_map_create()
void hb_map_destroy(hb_map_t *map)
HB_EXTERN hb_tag_t table_tag
#define HB_CLOSURE_MAX_STAGES
void hb_ot_layout_collect_features(hb_face_t *face, hb_tag_t table_tag, const hb_tag_t *scripts, const hb_tag_t *languages, const hb_tag_t *features, hb_set_t *feature_indexes)
hb_bool_t hb_ot_layout_has_positioning(hb_face_t *face)
void hb_ot_layout_lookups_substitute_closure(hb_face_t *face, const hb_set_t *lookups, hb_set_t *glyphs)
void hb_ot_layout_collect_lookups(hb_face_t *face, hb_tag_t table_tag, const hb_tag_t *scripts, const hb_tag_t *languages, const hb_tag_t *features, hb_set_t *lookup_indexes)
void hb_set_set(hb_set_t *set, const hb_set_t *other)
hb_set_t * hb_set_get_empty()
hb_set_t * hb_set_create()
void hb_set_destroy(hb_set_t *set)
hb_set_t * hb_set_copy(const hb_set_t *set)
const hb_map_t * hb_subset_plan_new_to_old_glyph_mapping(const hb_subset_plan_t *plan)
const hb_map_t * hb_subset_plan_old_to_new_glyph_mapping(const hb_subset_plan_t *plan)
hb_subset_plan_t * hb_subset_plan_reference(hb_subset_plan_t *plan)
const hb_map_t * hb_subset_plan_unicode_to_old_glyph_mapping(const hb_subset_plan_t *plan)
hb_subset_plan_t * hb_subset_plan_create_or_fail(hb_face_t *face, const hb_subset_input_t *input)
hb_bool_t hb_subset_plan_set_user_data(hb_subset_plan_t *plan, hb_user_data_key_t *key, void *data, hb_destroy_func_t destroy, hb_bool_t replace)
void * hb_subset_plan_get_user_data(const hb_subset_plan_t *plan, hb_user_data_key_t *key)
void(* layout_collect_func_t)(hb_face_t *face, hb_tag_t table_tag, const hb_tag_t *scripts, const hb_tag_t *languages, const hb_tag_t *features, hb_set_t *lookup_indexes)
hb_hashmap_t< unsigned, hb_set_t * > script_langsys_map
void hb_subset_plan_destroy(hb_subset_plan_t *plan)
@ HB_SUBSET_FLAGS_RETAIN_GIDS
GLenum GLenum GLsizei count
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLsizei GLenum const void * indices
GLenum GLenum GLenum GLenum mapping
GLenum GLenum GLenum input
GLenum GLenum GLsizei void * table
void(* hb_destroy_func_t)(void *user_data)
HB_BEGIN_DECLS typedef int hb_bool_t
HB_EXTERN hb_font_get_glyph_func_t void hb_destroy_func_t destroy
#define HB_SET_VALUE_INVALID
unsigned int get_num_glyphs() const
unsigned int get_population() const
auto iter() const HB_AUTO_RETURN(+hb_array(items
bool set(K key, const V &value)
bool next(hb_codepoint_t *codepoint) const
bool has(hb_codepoint_t k) const
unsigned int get_population() const
void union_(const hb_sparseset_t &other)
void del(hb_codepoint_t g)
void add(hb_codepoint_t g)
bool check_success(bool success)
hb_set_t * layout_variation_indices
hb_hashmap_t< unsigned, hb_set_t * > * gpos_langsys
hb_set_t * _glyphset_colred
hb_map_t * layout_variation_idx_map
hb_set_t * layout_features
unsigned int _num_output_glyphs
hb_map_t * codepoint_to_glyph
hb_hashmap_t< unsigned, hb_set_t * > * gsub_langsys
hb_set_t * _glyphset_gsub
hb_set_t * name_languages
hb_set_t * no_subset_tables
hb_set_t * glyphs_requested
hb_set_t * _glyphset_mathed
hb_map_t * reverse_glyph_map
bool alloc(unsigned int size)
XmlOutput::xml_output tag(const QString &name)