[machinery] Move accelerators to constructor/destructor
This commit is contained in:
parent
e062376ef1
commit
ac1bb3e39e
|
@ -244,19 +244,19 @@ struct hb_lazy_loader_t : hb_data_wrapper_t<Data, WheresData>
|
|||
{
|
||||
Stored *p = (Stored *) hb_calloc (1, sizeof (Stored));
|
||||
if (likely (p))
|
||||
p->Xinit (data);
|
||||
p = new (p) Stored (data);
|
||||
return p;
|
||||
}
|
||||
static Stored *create ()
|
||||
{
|
||||
Stored *p = (Stored *) hb_calloc (1, sizeof (Stored));
|
||||
if (likely (p))
|
||||
p->Xinit ();
|
||||
p = new (p) Stored ();
|
||||
return p;
|
||||
}
|
||||
static void destroy (Stored *p)
|
||||
{
|
||||
p->Xfini ();
|
||||
p->~Stored ();
|
||||
hb_free (p);
|
||||
}
|
||||
|
||||
|
|
|
@ -1270,7 +1270,7 @@ struct cff1
|
|||
|
||||
struct accelerator_t : accelerator_templ_t<cff1_private_dict_opset_t, cff1_private_dict_values_t>
|
||||
{
|
||||
void Xinit (hb_face_t *face)
|
||||
accelerator_t (hb_face_t *face)
|
||||
{
|
||||
SUPER::init (face);
|
||||
|
||||
|
@ -1295,8 +1295,7 @@ struct cff1
|
|||
}
|
||||
glyph_names.qsort ();
|
||||
}
|
||||
|
||||
void Xfini ()
|
||||
~accelerator_t ()
|
||||
{
|
||||
glyph_names.fini ();
|
||||
|
||||
|
@ -1398,7 +1397,10 @@ struct cff1
|
|||
DEFINE_SIZE_STATIC (4);
|
||||
};
|
||||
|
||||
struct cff1_accelerator_t : cff1::accelerator_t {};
|
||||
struct cff1_accelerator_t : cff1::accelerator_t {
|
||||
cff1_accelerator_t (hb_face_t *face) : cff1::accelerator_t (face) {}
|
||||
};
|
||||
|
||||
} /* namespace OT */
|
||||
|
||||
#endif /* HB_OT_CFF1_TABLE_HH */
|
||||
|
|
|
@ -397,7 +397,7 @@ struct cff2
|
|||
template <typename PRIVOPSET, typename PRIVDICTVAL>
|
||||
struct accelerator_templ_t
|
||||
{
|
||||
void Xinit (hb_face_t *face)
|
||||
accelerator_templ_t (hb_face_t *face)
|
||||
{
|
||||
topDict.init ();
|
||||
fontDicts.init ();
|
||||
|
@ -412,15 +412,15 @@ struct cff2
|
|||
const OT::cff2 *cff2 = this->blob->template as<OT::cff2> ();
|
||||
|
||||
if (cff2 == &Null (OT::cff2))
|
||||
{ Xfini (); return; }
|
||||
goto fail;
|
||||
|
||||
{ /* parse top dict */
|
||||
byte_str_t topDictStr (cff2 + cff2->topDict, cff2->topDictSize);
|
||||
if (unlikely (!topDictStr.sanitize (&sc))) { Xfini (); return; }
|
||||
if (unlikely (!topDictStr.sanitize (&sc))) goto fail;
|
||||
cff2_top_dict_interpreter_t top_interp;
|
||||
top_interp.env.init (topDictStr);
|
||||
topDict.init ();
|
||||
if (unlikely (!top_interp.interpret (topDict))) { Xfini (); return; }
|
||||
if (unlikely (!top_interp.interpret (topDict))) goto fail;
|
||||
}
|
||||
|
||||
globalSubrs = &StructAtOffset<CFF2Subrs> (cff2, cff2->topDict + cff2->topDictSize);
|
||||
|
@ -434,44 +434,50 @@ struct cff2
|
|||
(globalSubrs == &Null (CFF2Subrs)) || unlikely (!globalSubrs->sanitize (&sc)) ||
|
||||
(fdArray == &Null (CFF2FDArray)) || unlikely (!fdArray->sanitize (&sc)) ||
|
||||
(((fdSelect != &Null (CFF2FDSelect)) && unlikely (!fdSelect->sanitize (&sc, fdArray->count)))))
|
||||
{ Xfini (); return; }
|
||||
goto fail;
|
||||
|
||||
num_glyphs = charStrings->count;
|
||||
if (num_glyphs != sc.get_num_glyphs ())
|
||||
{ Xfini (); return; }
|
||||
goto fail;
|
||||
|
||||
fdCount = fdArray->count;
|
||||
if (!privateDicts.resize (fdCount))
|
||||
{ Xfini (); return; }
|
||||
goto fail;
|
||||
|
||||
/* parse font dicts and gather private dicts */
|
||||
for (unsigned int i = 0; i < fdCount; i++)
|
||||
{
|
||||
const byte_str_t fontDictStr = (*fdArray)[i];
|
||||
if (unlikely (!fontDictStr.sanitize (&sc))) { Xfini (); return; }
|
||||
if (unlikely (!fontDictStr.sanitize (&sc))) goto fail;
|
||||
cff2_font_dict_values_t *font;
|
||||
cff2_font_dict_interpreter_t font_interp;
|
||||
font_interp.env.init (fontDictStr);
|
||||
font = fontDicts.push ();
|
||||
if (unlikely (font == &Crap (cff2_font_dict_values_t))) { Xfini (); return; }
|
||||
if (unlikely (font == &Crap (cff2_font_dict_values_t))) goto fail;
|
||||
font->init ();
|
||||
if (unlikely (!font_interp.interpret (*font))) { Xfini (); return; }
|
||||
if (unlikely (!font_interp.interpret (*font))) goto fail;
|
||||
|
||||
const byte_str_t privDictStr (StructAtOffsetOrNull<UnsizedByteStr> (cff2, font->privateDictInfo.offset), font->privateDictInfo.size);
|
||||
if (unlikely (!privDictStr.sanitize (&sc))) { Xfini (); return; }
|
||||
if (unlikely (!privDictStr.sanitize (&sc))) goto fail;
|
||||
dict_interpreter_t<PRIVOPSET, PRIVDICTVAL, cff2_priv_dict_interp_env_t> priv_interp;
|
||||
priv_interp.env.init(privDictStr);
|
||||
privateDicts[i].init ();
|
||||
if (unlikely (!priv_interp.interpret (privateDicts[i]))) { Xfini (); return; }
|
||||
if (unlikely (!priv_interp.interpret (privateDicts[i]))) goto fail;
|
||||
|
||||
privateDicts[i].localSubrs = &StructAtOffsetOrNull<CFF2Subrs> (&privDictStr[0], privateDicts[i].subrsOffset);
|
||||
if (privateDicts[i].localSubrs != &Null (CFF2Subrs) &&
|
||||
unlikely (!privateDicts[i].localSubrs->sanitize (&sc)))
|
||||
{ Xfini (); return; }
|
||||
}
|
||||
goto fail;
|
||||
}
|
||||
|
||||
void Xfini ()
|
||||
|
||||
return;
|
||||
|
||||
fail:
|
||||
_fini ();
|
||||
}
|
||||
~accelerator_templ_t () { _fini (); }
|
||||
void _fini ()
|
||||
{
|
||||
sc.end_processing ();
|
||||
topDict.fini ();
|
||||
|
@ -504,6 +510,8 @@ struct cff2
|
|||
|
||||
struct accelerator_t : accelerator_templ_t<cff2_private_dict_opset_t, cff2_private_dict_values_t>
|
||||
{
|
||||
accelerator_t (hb_face_t *face) : accelerator_templ_t (face) {}
|
||||
|
||||
HB_INTERNAL bool get_extents (hb_font_t *font,
|
||||
hb_codepoint_t glyph,
|
||||
hb_glyph_extents_t *extents) const;
|
||||
|
@ -525,7 +533,10 @@ struct cff2
|
|||
DEFINE_SIZE_STATIC (5);
|
||||
};
|
||||
|
||||
struct cff2_accelerator_t : cff2::accelerator_t {};
|
||||
struct cff2_accelerator_t : cff2::accelerator_t {
|
||||
cff2_accelerator_t (hb_face_t *face) : cff2::accelerator_t (face) {}
|
||||
};
|
||||
|
||||
} /* namespace OT */
|
||||
|
||||
#endif /* HB_OT_CFF2_TABLE_HH */
|
||||
|
|
|
@ -368,10 +368,9 @@ struct CmapSubtableFormat4
|
|||
struct accelerator_t
|
||||
{
|
||||
accelerator_t () {}
|
||||
accelerator_t (const CmapSubtableFormat4 *subtable) { Xinit (subtable); }
|
||||
~accelerator_t () { Xfini (); }
|
||||
accelerator_t (const CmapSubtableFormat4 *subtable) { init (subtable); }
|
||||
|
||||
void Xinit (const CmapSubtableFormat4 *subtable)
|
||||
void init (const CmapSubtableFormat4 *subtable)
|
||||
{
|
||||
segCount = subtable->segCountX2 / 2;
|
||||
endCount = subtable->values.arrayZ;
|
||||
|
@ -381,7 +380,6 @@ struct CmapSubtableFormat4
|
|||
glyphIdArray = idRangeOffset + segCount;
|
||||
glyphIdArrayLength = (subtable->length - 16 - 8 * segCount) / 2;
|
||||
}
|
||||
void Xfini () {}
|
||||
|
||||
bool get_glyph (hb_codepoint_t codepoint, hb_codepoint_t *glyph) const
|
||||
{
|
||||
|
@ -1665,7 +1663,7 @@ struct cmap
|
|||
|
||||
struct accelerator_t
|
||||
{
|
||||
void Xinit (hb_face_t *face)
|
||||
accelerator_t (hb_face_t *face)
|
||||
{
|
||||
this->table = hb_sanitize_context_t ().reference_table<cmap> (face);
|
||||
bool symbol;
|
||||
|
@ -1692,7 +1690,7 @@ struct cmap
|
|||
break;
|
||||
case 4:
|
||||
{
|
||||
this->format4_accel.Xinit (&subtable->u.format4);
|
||||
this->format4_accel.init (&subtable->u.format4);
|
||||
this->get_glyph_data = &this->format4_accel;
|
||||
this->get_glyph_funcZ = this->format4_accel.get_glyph_func;
|
||||
break;
|
||||
|
@ -1700,8 +1698,7 @@ struct cmap
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Xfini () { this->table.destroy (); }
|
||||
~accelerator_t () { this->table.destroy (); }
|
||||
|
||||
bool get_nominal_glyph (hb_codepoint_t unicode,
|
||||
hb_codepoint_t *glyph) const
|
||||
|
@ -1863,7 +1860,9 @@ struct cmap
|
|||
DEFINE_SIZE_ARRAY (4, encodingRecord);
|
||||
};
|
||||
|
||||
struct cmap_accelerator_t : cmap::accelerator_t {};
|
||||
struct cmap_accelerator_t : cmap::accelerator_t {
|
||||
cmap_accelerator_t (hb_face_t *face) : cmap::accelerator_t (face) {}
|
||||
};
|
||||
|
||||
} /* namespace OT */
|
||||
|
||||
|
|
|
@ -819,15 +819,14 @@ struct CBDT
|
|||
|
||||
struct accelerator_t
|
||||
{
|
||||
void Xinit (hb_face_t *face)
|
||||
accelerator_t (hb_face_t *face)
|
||||
{
|
||||
cblc = hb_sanitize_context_t ().reference_table<CBLC> (face);
|
||||
cbdt = hb_sanitize_context_t ().reference_table<CBDT> (face);
|
||||
this->cblc = hb_sanitize_context_t ().reference_table<CBLC> (face);
|
||||
this->cbdt = hb_sanitize_context_t ().reference_table<CBDT> (face);
|
||||
|
||||
upem = hb_face_get_upem (face);
|
||||
}
|
||||
|
||||
void Xfini ()
|
||||
~accelerator_t ()
|
||||
{
|
||||
this->cblc.destroy ();
|
||||
this->cbdt.destroy ();
|
||||
|
@ -988,7 +987,10 @@ CBLC::subset (hb_subset_context_t *c) const
|
|||
return_trace (CBLC::sink_cbdt (c, &cbdt_prime));
|
||||
}
|
||||
|
||||
struct CBDT_accelerator_t : CBDT::accelerator_t {};
|
||||
struct CBDT_accelerator_t : CBDT::accelerator_t {
|
||||
CBDT_accelerator_t (hb_face_t *face) : CBDT::accelerator_t (face) {}
|
||||
};
|
||||
|
||||
|
||||
} /* namespace OT */
|
||||
|
||||
|
|
|
@ -202,12 +202,12 @@ struct sbix
|
|||
|
||||
struct accelerator_t
|
||||
{
|
||||
void Xinit (hb_face_t *face)
|
||||
accelerator_t (hb_face_t *face)
|
||||
{
|
||||
table = hb_sanitize_context_t ().reference_table<sbix> (face);
|
||||
num_glyphs = face->get_num_glyphs ();
|
||||
}
|
||||
void Xfini () { table.destroy (); }
|
||||
~accelerator_t () { table.destroy (); }
|
||||
|
||||
bool has_data () const { return table->has_data (); }
|
||||
|
||||
|
@ -407,7 +407,10 @@ struct sbix
|
|||
DEFINE_SIZE_ARRAY (8, strikes);
|
||||
};
|
||||
|
||||
struct sbix_accelerator_t : sbix::accelerator_t {};
|
||||
struct sbix_accelerator_t : sbix::accelerator_t {
|
||||
sbix_accelerator_t (hb_face_t *face) : sbix::accelerator_t (face) {}
|
||||
};
|
||||
|
||||
|
||||
} /* namespace OT */
|
||||
|
||||
|
|
|
@ -79,9 +79,9 @@ struct SVG
|
|||
|
||||
struct accelerator_t
|
||||
{
|
||||
void Xinit (hb_face_t *face)
|
||||
accelerator_t (hb_face_t *face)
|
||||
{ table = hb_sanitize_context_t ().reference_table<SVG> (face); }
|
||||
void Xfini () { table.destroy (); }
|
||||
~accelerator_t () { table.destroy (); }
|
||||
|
||||
hb_blob_t *reference_blob_for_glyph (hb_codepoint_t glyph_id) const
|
||||
{
|
||||
|
@ -116,7 +116,9 @@ struct SVG
|
|||
DEFINE_SIZE_STATIC (10);
|
||||
};
|
||||
|
||||
struct SVG_accelerator_t : SVG::accelerator_t {};
|
||||
struct SVG_accelerator_t : SVG::accelerator_t {
|
||||
SVG_accelerator_t (hb_face_t *face) : SVG::accelerator_t (face) {}
|
||||
};
|
||||
|
||||
} /* namespace OT */
|
||||
|
||||
|
|
|
@ -207,8 +207,7 @@ struct glyf
|
|||
_populate_subset_glyphs (const hb_subset_plan_t *plan,
|
||||
hb_vector_t<SubsetGlyph> *glyphs /* OUT */) const
|
||||
{
|
||||
OT::glyf::accelerator_t glyf;
|
||||
glyf.Xinit (plan->source);
|
||||
OT::glyf::accelerator_t glyf (plan->source);
|
||||
|
||||
+ hb_range (plan->num_output_glyphs ())
|
||||
| hb_map ([&] (hb_codepoint_t new_gid)
|
||||
|
@ -233,8 +232,6 @@ struct glyf
|
|||
})
|
||||
| hb_sink (glyphs)
|
||||
;
|
||||
|
||||
glyf.Xfini ();
|
||||
}
|
||||
|
||||
static bool
|
||||
|
@ -920,7 +917,7 @@ struct glyf
|
|||
|
||||
struct accelerator_t
|
||||
{
|
||||
void Xinit (hb_face_t *face_)
|
||||
accelerator_t (hb_face_t *face_)
|
||||
{
|
||||
short_offset = false;
|
||||
num_glyphs = 0;
|
||||
|
@ -953,8 +950,7 @@ struct glyf
|
|||
num_glyphs = hb_max (1u, loca_table.get_length () / (short_offset ? 2 : 4)) - 1;
|
||||
num_glyphs = hb_min (num_glyphs, face->get_num_glyphs ());
|
||||
}
|
||||
|
||||
void Xfini ()
|
||||
~accelerator_t ()
|
||||
{
|
||||
loca_table.destroy ();
|
||||
glyf_table.destroy ();
|
||||
|
@ -1358,7 +1354,10 @@ struct glyf
|
|||
* defining it _MIN instead. */
|
||||
};
|
||||
|
||||
struct glyf_accelerator_t : glyf::accelerator_t {};
|
||||
struct glyf_accelerator_t : glyf::accelerator_t {
|
||||
glyf_accelerator_t (hb_face_t *face) : glyf::accelerator_t (face) {}
|
||||
};
|
||||
|
||||
|
||||
} /* namespace OT */
|
||||
|
||||
|
|
|
@ -127,8 +127,7 @@ struct hmtxvmtx
|
|||
T *table_prime = c->serializer->start_embed <T> ();
|
||||
if (unlikely (!table_prime)) return_trace (false);
|
||||
|
||||
accelerator_t _mtx;
|
||||
_mtx.Xinit (c->plan->source);
|
||||
accelerator_t _mtx (c->plan->source);
|
||||
unsigned num_advances = _mtx.num_advances_for_subset (c->plan);
|
||||
|
||||
auto it =
|
||||
|
@ -144,8 +143,6 @@ struct hmtxvmtx
|
|||
|
||||
table_prime->serialize (c->serializer, it, num_advances);
|
||||
|
||||
_mtx.Xfini ();
|
||||
|
||||
if (unlikely (c->serializer->in_error ()))
|
||||
return_trace (false);
|
||||
|
||||
|
@ -160,7 +157,7 @@ struct hmtxvmtx
|
|||
{
|
||||
friend struct hmtxvmtx;
|
||||
|
||||
void Xinit (hb_face_t *face,
|
||||
accelerator_t (hb_face_t *face,
|
||||
unsigned int default_advance_ = 0)
|
||||
{
|
||||
default_advance = default_advance_ ? default_advance_ : hb_face_get_upem (face);
|
||||
|
@ -193,8 +190,7 @@ struct hmtxvmtx
|
|||
|
||||
var_table = hb_sanitize_context_t ().reference_table<HVARVVAR> (face, T::variationsTag);
|
||||
}
|
||||
|
||||
void Xfini ()
|
||||
~accelerator_t ()
|
||||
{
|
||||
table.destroy ();
|
||||
var_table.destroy ();
|
||||
|
@ -338,8 +334,12 @@ struct vmtx : hmtxvmtx<vmtx, vhea> {
|
|||
static constexpr bool is_horizontal = false;
|
||||
};
|
||||
|
||||
struct hmtx_accelerator_t : hmtx::accelerator_t {};
|
||||
struct vmtx_accelerator_t : vmtx::accelerator_t {};
|
||||
struct hmtx_accelerator_t : hmtx::accelerator_t {
|
||||
hmtx_accelerator_t (hb_face_t *face) : hmtx::accelerator_t (face) {}
|
||||
};
|
||||
struct vmtx_accelerator_t : vmtx::accelerator_t {
|
||||
vmtx_accelerator_t (hb_face_t *face) : vmtx::accelerator_t (face) {}
|
||||
};
|
||||
|
||||
} /* namespace OT */
|
||||
|
||||
|
|
|
@ -585,7 +585,7 @@ struct GDEF
|
|||
|
||||
struct accelerator_t
|
||||
{
|
||||
void Xinit (hb_face_t *face)
|
||||
accelerator_t (hb_face_t *face)
|
||||
{
|
||||
this->table = hb_sanitize_context_t ().reference_table<GDEF> (face);
|
||||
if (unlikely (this->table->is_blocklisted (this->table.get_blob (), face)))
|
||||
|
@ -594,8 +594,7 @@ struct GDEF
|
|||
this->table = hb_blob_get_empty ();
|
||||
}
|
||||
}
|
||||
|
||||
void Xfini () { this->table.destroy (); }
|
||||
~accelerator_t () { this->table.destroy (); }
|
||||
|
||||
hb_blob_ptr_t<GDEF> table;
|
||||
};
|
||||
|
@ -715,7 +714,9 @@ struct GDEF
|
|||
DEFINE_SIZE_MIN (12);
|
||||
};
|
||||
|
||||
struct GDEF_accelerator_t : GDEF::accelerator_t {};
|
||||
struct GDEF_accelerator_t : GDEF::accelerator_t {
|
||||
GDEF_accelerator_t (hb_face_t *face) : GDEF::accelerator_t (face) {}
|
||||
};
|
||||
|
||||
} /* namespace OT */
|
||||
|
||||
|
|
|
@ -2973,7 +2973,9 @@ GPOS::position_finish_offsets (hb_font_t *font, hb_buffer_t *buffer)
|
|||
}
|
||||
|
||||
|
||||
struct GPOS_accelerator_t : GPOS::accelerator_t {};
|
||||
struct GPOS_accelerator_t : GPOS::accelerator_t {
|
||||
GPOS_accelerator_t (hb_face_t *face) : GPOS::accelerator_t (face) {}
|
||||
};
|
||||
|
||||
|
||||
/* Out-of-class implementation for methods recursing */
|
||||
|
|
|
@ -1739,7 +1739,9 @@ struct GSUB : GSUBGPOS
|
|||
};
|
||||
|
||||
|
||||
struct GSUB_accelerator_t : GSUB::accelerator_t {};
|
||||
struct GSUB_accelerator_t : GSUB::accelerator_t {
|
||||
GSUB_accelerator_t (hb_face_t *face) : GSUB::accelerator_t (face) {}
|
||||
};
|
||||
|
||||
|
||||
/* Out-of-class implementation for methods recursing */
|
||||
|
|
|
@ -3846,7 +3846,7 @@ struct GSUBGPOS
|
|||
template <typename T>
|
||||
struct accelerator_t
|
||||
{
|
||||
void Xinit (hb_face_t *face)
|
||||
accelerator_t (hb_face_t *face)
|
||||
{
|
||||
this->table = hb_sanitize_context_t ().reference_table<T> (face);
|
||||
if (unlikely (this->table->is_blocklisted (this->table.get_blob (), face)))
|
||||
|
@ -3868,8 +3868,7 @@ struct GSUBGPOS
|
|||
for (unsigned int i = 0; i < this->lookup_count; i++)
|
||||
this->accels[i].init (table->get_lookup (i));
|
||||
}
|
||||
|
||||
void Xfini ()
|
||||
~accelerator_t ()
|
||||
{
|
||||
for (unsigned int i = 0; i < this->lookup_count; i++)
|
||||
this->accels[i].fini ();
|
||||
|
|
|
@ -71,9 +71,9 @@ struct meta
|
|||
|
||||
struct accelerator_t
|
||||
{
|
||||
void Xinit (hb_face_t *face)
|
||||
accelerator_t (hb_face_t *face)
|
||||
{ table = hb_sanitize_context_t ().reference_table<meta> (face); }
|
||||
void Xfini () { table.destroy (); }
|
||||
~accelerator_t () { table.destroy (); }
|
||||
|
||||
hb_blob_t *reference_entry (hb_tag_t tag) const
|
||||
{ return table->dataMaps.lsearch (tag).reference_entry (table.get_blob ()); }
|
||||
|
@ -119,7 +119,9 @@ struct meta
|
|||
DEFINE_SIZE_ARRAY (16, dataMaps);
|
||||
};
|
||||
|
||||
struct meta_accelerator_t : meta::accelerator_t {};
|
||||
struct meta_accelerator_t : meta::accelerator_t {
|
||||
meta_accelerator_t (hb_face_t *face) : meta::accelerator_t (face) {}
|
||||
};
|
||||
|
||||
} /* namespace OT */
|
||||
|
||||
|
|
|
@ -279,7 +279,7 @@ struct name
|
|||
|
||||
struct accelerator_t
|
||||
{
|
||||
void Xinit (hb_face_t *face)
|
||||
accelerator_t (hb_face_t *face)
|
||||
{
|
||||
this->table = hb_sanitize_context_t ().reference_table<name> (face);
|
||||
assert (this->table.get_length () >= this->table->stringOffset);
|
||||
|
@ -318,8 +318,7 @@ struct name
|
|||
}
|
||||
this->names.resize (j);
|
||||
}
|
||||
|
||||
void Xfini ()
|
||||
~accelerator_t ()
|
||||
{
|
||||
this->names.fini ();
|
||||
this->table.destroy ();
|
||||
|
@ -373,7 +372,9 @@ struct name
|
|||
#undef entry_index
|
||||
#undef entry_score
|
||||
|
||||
struct name_accelerator_t : name::accelerator_t {};
|
||||
struct name_accelerator_t : name::accelerator_t {
|
||||
name_accelerator_t (hb_face_t *face) : name::accelerator_t (face) {}
|
||||
};
|
||||
|
||||
} /* namespace OT */
|
||||
|
||||
|
|
|
@ -76,8 +76,7 @@ HB_INTERNAL bool postV2Tail::subset (hb_subset_context_t *c) const
|
|||
hb_map_t old_new_index_map, old_gid_new_index_map;
|
||||
unsigned i = 0;
|
||||
|
||||
post::accelerator_t _post;
|
||||
_post.Xinit (c->plan->source);
|
||||
post::accelerator_t _post (c->plan->source);
|
||||
|
||||
hb_hashmap_t<hb_bytes_t, unsigned, std::nullptr_t, unsigned, nullptr, (unsigned)-1> glyph_name_to_new_index;
|
||||
for (hb_codepoint_t new_gid = 0; new_gid < num_glyphs; new_gid++)
|
||||
|
@ -128,9 +127,7 @@ HB_INTERNAL bool postV2Tail::subset (hb_subset_context_t *c) const
|
|||
})
|
||||
;
|
||||
|
||||
bool ret = serialize (c->serializer, index_iter, &_post);
|
||||
_post.Xfini ();
|
||||
return_trace (ret);
|
||||
return_trace (serialize (c->serializer, index_iter, &_post));
|
||||
}
|
||||
|
||||
} /* namespace OT */
|
||||
|
|
|
@ -111,7 +111,8 @@ struct post
|
|||
struct accelerator_t
|
||||
{
|
||||
friend struct postV2Tail;
|
||||
void Xinit (hb_face_t *face)
|
||||
|
||||
accelerator_t (hb_face_t *face)
|
||||
{
|
||||
index_to_offset.init ();
|
||||
|
||||
|
@ -132,7 +133,7 @@ struct post
|
|||
data += 1 + *data)
|
||||
index_to_offset.push (data - pool);
|
||||
}
|
||||
void Xfini ()
|
||||
~accelerator_t ()
|
||||
{
|
||||
index_to_offset.fini ();
|
||||
hb_free (gids_sorted_by_name.get ());
|
||||
|
@ -307,7 +308,10 @@ struct post
|
|||
DEFINE_SIZE_MIN (32);
|
||||
};
|
||||
|
||||
struct post_accelerator_t : post::accelerator_t {};
|
||||
struct post_accelerator_t : post::accelerator_t {
|
||||
post_accelerator_t (hb_face_t *face) : post::accelerator_t (face) {}
|
||||
};
|
||||
|
||||
|
||||
} /* namespace OT */
|
||||
|
||||
|
|
|
@ -498,9 +498,9 @@ struct gvar
|
|||
public:
|
||||
struct accelerator_t
|
||||
{
|
||||
void Xinit (hb_face_t *face)
|
||||
accelerator_t (hb_face_t *face)
|
||||
{ table = hb_sanitize_context_t ().reference_table<gvar> (face); }
|
||||
void Xfini () { table.destroy (); }
|
||||
~accelerator_t () { table.destroy (); }
|
||||
|
||||
private:
|
||||
struct x_getter { static float get (const contour_point_t &p) { return p.x; } };
|
||||
|
@ -698,7 +698,9 @@ no_more_gaps:
|
|||
DEFINE_SIZE_MIN (20);
|
||||
};
|
||||
|
||||
struct gvar_accelerator_t : gvar::accelerator_t {};
|
||||
struct gvar_accelerator_t : gvar::accelerator_t {
|
||||
gvar_accelerator_t (hb_face_t *face) : gvar::accelerator_t (face) {}
|
||||
};
|
||||
|
||||
} /* namespace OT */
|
||||
|
||||
|
|
|
@ -450,12 +450,8 @@ _hb_subset_cff2 (const OT::cff2::accelerator_subset_t &acc,
|
|||
bool
|
||||
hb_subset_cff2 (hb_subset_context_t *c)
|
||||
{
|
||||
OT::cff2::accelerator_subset_t acc;
|
||||
acc.Xinit (c->plan->source);
|
||||
bool result = likely (acc.is_valid ()) && _hb_subset_cff2 (acc, c);
|
||||
acc.Xfini ();
|
||||
|
||||
return result;
|
||||
OT::cff2::accelerator_subset_t acc (c->plan->source);
|
||||
return acc.is_valid () && _hb_subset_cff2 (acc, c);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -228,10 +228,8 @@ _cmap_closure (hb_face_t *face,
|
|||
const hb_set_t *unicodes,
|
||||
hb_set_t *glyphset)
|
||||
{
|
||||
OT::cmap::accelerator_t cmap;
|
||||
cmap.Xinit (face);
|
||||
OT::cmap::accelerator_t cmap (face);
|
||||
cmap.table->closure_glyphs (unicodes, glyphset);
|
||||
cmap.Xfini ();
|
||||
}
|
||||
|
||||
static void _colr_closure (hb_face_t *face,
|
||||
|
@ -294,8 +292,7 @@ _populate_unicodes_to_retain (const hb_set_t *unicodes,
|
|||
const hb_set_t *glyphs,
|
||||
hb_subset_plan_t *plan)
|
||||
{
|
||||
OT::cmap::accelerator_t cmap;
|
||||
cmap.Xinit (plan->source);
|
||||
OT::cmap::accelerator_t cmap (plan->source);
|
||||
|
||||
constexpr static const int size_threshold = 4096;
|
||||
|
||||
|
@ -343,8 +340,6 @@ _populate_unicodes_to_retain (const hb_set_t *unicodes,
|
|||
|
||||
+ plan->codepoint_to_glyph->keys () | hb_sink (plan->unicodes);
|
||||
+ plan->codepoint_to_glyph->values () | hb_sink (plan->_glyphset_gsub);
|
||||
|
||||
cmap.Xfini ();
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -353,13 +348,9 @@ _populate_gids_to_retain (hb_subset_plan_t* plan,
|
|||
bool close_over_gpos,
|
||||
bool close_over_gdef)
|
||||
{
|
||||
OT::glyf::accelerator_t glyf;
|
||||
OT::glyf::accelerator_t glyf (plan->source);
|
||||
#ifndef HB_NO_SUBSET_CFF
|
||||
OT::cff1::accelerator_t cff;
|
||||
#endif
|
||||
glyf.Xinit (plan->source);
|
||||
#ifndef HB_NO_SUBSET_CFF
|
||||
cff.Xinit (plan->source);
|
||||
OT::cff1::accelerator_t cff (plan->source);
|
||||
#endif
|
||||
|
||||
plan->_glyphset_gsub->add (0); // Not-def
|
||||
|
@ -419,11 +410,6 @@ _populate_gids_to_retain (hb_subset_plan_t* plan,
|
|||
plan->layout_variation_indices,
|
||||
plan->layout_variation_idx_map);
|
||||
#endif
|
||||
|
||||
#ifndef HB_NO_SUBSET_CFF
|
||||
cff.Xfini ();
|
||||
#endif
|
||||
glyf.Xfini ();
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
Loading…
Reference in New Issue