[subset/cff] Use a typedef for glyph_to_sid_map_t

This commit is contained in:
Behdad Esfahbod 2023-06-26 14:02:26 -06:00
parent 6783701b4e
commit d3f90a8ca7
4 changed files with 14 additions and 12 deletions

View file

@ -52,8 +52,10 @@ struct code_pair_t
hb_codepoint_t glyph;
};
using str_buff_t = hb_vector_t<unsigned char>;
using str_buff_vec_t = hb_vector_t<str_buff_t>;
using glyph_to_sid_map_t = hb_vector_t<uint16_t>;
/* CFF INDEX */
template <typename COUNT>

View file

@ -330,7 +330,7 @@ struct Charset0
return sids[glyph - 1];
}
void collect_glyph_to_sid_map (hb_vector_t<uint16_t> *mapping, unsigned int num_glyphs) const
void collect_glyph_to_sid_map (glyph_to_sid_map_t *mapping, unsigned int num_glyphs) const
{
mapping->resize (num_glyphs, false);
for (hb_codepoint_t gid = 1; gid < num_glyphs; gid++)
@ -430,7 +430,7 @@ struct Charset1_2 {
return 0;
}
void collect_glyph_to_sid_map (hb_vector_t<uint16_t> *mapping, unsigned int num_glyphs) const
void collect_glyph_to_sid_map (glyph_to_sid_map_t *mapping, unsigned int num_glyphs) const
{
mapping->resize (num_glyphs, false);
hb_codepoint_t gid = 1;
@ -589,7 +589,7 @@ struct Charset
}
}
void collect_glyph_to_sid_map (hb_vector_t<uint16_t> *mapping, unsigned int num_glyphs) const
void collect_glyph_to_sid_map (glyph_to_sid_map_t *mapping, unsigned int num_glyphs) const
{
switch (format)
{
@ -1268,13 +1268,13 @@ struct cff1
}
}
hb_vector_t<uint16_t> *create_glyph_to_sid_map () const
glyph_to_sid_map_t *create_glyph_to_sid_map () const
{
if (charset != &Null (Charset))
{
auto *mapping = (hb_vector_t<uint16_t> *) hb_malloc (sizeof (hb_vector_t<uint16_t>));
auto *mapping = (glyph_to_sid_map_t *) hb_malloc (sizeof (glyph_to_sid_map_t));
if (unlikely (!mapping)) return nullptr;
mapping = new (mapping) hb_vector_t<uint16_t> ();
mapping = new (mapping) glyph_to_sid_map_t ();
mapping->push (0);
charset->collect_glyph_to_sid_map (mapping, num_glyphs);
return mapping;

View file

@ -517,7 +517,7 @@ struct cff_subset_accelerator_t
auto *mapping = glyph_to_sid_map.get_relaxed ();
if (mapping)
{
mapping->~hb_vector_t ();
mapping->~glyph_to_sid_map_t ();
hb_free (mapping);
}
}
@ -525,7 +525,7 @@ struct cff_subset_accelerator_t
parsed_cs_str_vec_t parsed_charstrings;
parsed_cs_str_vec_t parsed_global_subrs;
hb_vector_t<parsed_cs_str_vec_t> parsed_local_subrs;
mutable hb_atomic_ptr_t<hb_vector_t<uint16_t>> glyph_to_sid_map;
mutable hb_atomic_ptr_t<glyph_to_sid_map_t> glyph_to_sid_map;
private:
hb_blob_t* original_blob;

View file

@ -519,9 +519,9 @@ struct cff1_subset_plan
return;
}
hb_vector_t<uint16_t> *glyph_to_sid_map = acc.cff_accelerator ?
acc.cff_accelerator->glyph_to_sid_map.get_acquire () :
nullptr;
glyph_to_sid_map_t *glyph_to_sid_map = acc.cff_accelerator ?
acc.cff_accelerator->glyph_to_sid_map.get_acquire () :
nullptr;
bool created_map = false;
if (!glyph_to_sid_map && acc.cff_accelerator)
{
@ -566,7 +566,7 @@ struct cff1_subset_plan
if ((!plan->accelerator && acc.cff_accelerator) ||
!acc.cff_accelerator->glyph_to_sid_map.cmpexch (nullptr, glyph_to_sid_map))
{
glyph_to_sid_map->~hb_vector_t ();
glyph_to_sid_map->~glyph_to_sid_map_t ();
hb_free (glyph_to_sid_map);
}
}