[ot-face] Use core tables

This commit is contained in:
Behdad Esfahbod 2022-02-15 18:02:53 -06:00
parent 2a430790ad
commit c8fd8c1337
3 changed files with 5 additions and 23 deletions

View File

@ -80,6 +80,7 @@ HB_OT_TABLE (OT, VORG)
#endif #endif
/* TrueType outlines. */ /* TrueType outlines. */
HB_OT_CORE_TABLE (OT, loca) // Also used to determine number of glyphs
HB_OT_ACCELERATOR (OT, glyf) HB_OT_ACCELERATOR (OT, glyf)
/* CFF outlines. */ /* CFF outlines. */

View File

@ -936,7 +936,7 @@ struct glyf
return; return;
short_offset = 0 == head.indexToLocFormat; short_offset = 0 == head.indexToLocFormat;
loca_table = hb_sanitize_context_t ().reference_table<loca> (face); loca_table = face->table.loca.get_blob (); // Needs no destruct!
glyf_table = hb_sanitize_context_t ().reference_table<glyf> (face); glyf_table = hb_sanitize_context_t ().reference_table<glyf> (face);
#ifndef HB_NO_VAR #ifndef HB_NO_VAR
gvar = face->table.gvar; gvar = face->table.gvar;
@ -951,7 +951,6 @@ struct glyf
} }
~accelerator_t () ~accelerator_t ()
{ {
loca_table.destroy ();
glyf_table.destroy (); glyf_table.destroy ();
} }

View File

@ -60,23 +60,14 @@ static inline unsigned
load_num_glyphs_from_loca (const hb_face_t *face) load_num_glyphs_from_loca (const hb_face_t *face)
{ {
unsigned ret = 0; unsigned ret = 0;
hb_sanitize_context_t c = hb_sanitize_context_t ();
c.set_num_glyphs (0); /* So we don't recurse ad infinitum. */
/* We cannot use table.head because that would use sanitizer, unsigned indexToLocFormat = face->table.head->indexToLocFormat;
* which would try accessing face.num_glyphs, which would
* recurse here again... */
hb_blob_t *head_blob = c.reference_table<OT::head> (face);
const OT::head *head_table = head_blob->as<OT::head> ();
unsigned indexToLocFormat = head_table->indexToLocFormat;
hb_blob_destroy (head_blob);
if (indexToLocFormat <= 1) if (indexToLocFormat <= 1)
{ {
bool short_offset = 0 == indexToLocFormat; bool short_offset = 0 == indexToLocFormat;
hb_blob_t *loca_blob = c.reference_table<OT::loca> (face); hb_blob_t *loca_blob = face->table.loca.get_blob ();
ret = hb_max (1u, loca_blob->length / (short_offset ? 2 : 4)) - 1; ret = hb_max (1u, loca_blob->length / (short_offset ? 2 : 4)) - 1;
hb_blob_destroy (loca_blob);
} }
return ret; return ret;
@ -85,16 +76,7 @@ load_num_glyphs_from_loca (const hb_face_t *face)
static inline unsigned static inline unsigned
load_num_glyphs_from_maxp (const hb_face_t *face) load_num_glyphs_from_maxp (const hb_face_t *face)
{ {
unsigned ret = 0; return face->table.maxp->get_num_glyphs ();
hb_sanitize_context_t c = hb_sanitize_context_t ();
c.set_num_glyphs (0); /* So we don't recurse ad infinitum. */
hb_blob_t *maxp_blob = c.reference_table<OT::maxp> (face);
const OT::maxp *maxp_table = maxp_blob->as<OT::maxp> ();
ret = maxp_table->get_num_glyphs ();
hb_blob_destroy (maxp_blob);
return ret;
} }
unsigned int unsigned int