Set num glyphs on sanitizer reference_table()

Move out-of-class definitions of two methods to hb-static so they
are accessible in libharfbuzz-subset.
This commit is contained in:
Behdad Esfahbod 2018-07-23 11:46:46 -07:00
parent 9401829d4e
commit c6bc7c3831
3 changed files with 23 additions and 20 deletions

View File

@ -31,8 +31,6 @@
#include "hb-face-private.hh"
#include "hb-blob-private.hh"
#include "hb-open-file-private.hh"
#include "hb-ot-head-table.hh"
#include "hb-ot-maxp-table.hh"
@ -448,15 +446,6 @@ hb_face_get_upem (hb_face_t *face)
return face->get_upem ();
}
void
hb_face_t::load_upem (void) const
{
hb_blob_t *head_blob = OT::hb_sanitize_context_t().reference_table<OT::head> (this);
const OT::head *head_table = head_blob->as<OT::head> ();
upem = head_table->get_upem ();
hb_blob_destroy (head_blob);
}
/**
* hb_face_set_glyph_count:
* @face: a face.
@ -492,15 +481,6 @@ hb_face_get_glyph_count (hb_face_t *face)
return face->get_num_glyphs ();
}
void
hb_face_t::load_num_glyphs (void) const
{
hb_blob_t *maxp_blob = OT::hb_sanitize_context_t().reference_table<OT::maxp> (this);
const OT::maxp *maxp_table = maxp_blob->as<OT::maxp> ();
num_glyphs = maxp_table->get_num_glyphs ();
hb_blob_destroy (maxp_blob);
}
/**
* hb_face_get_table_tags:
* @face: a face.

View File

@ -348,6 +348,7 @@ struct hb_sanitize_context_t :
template <typename Type>
inline hb_blob_t *reference_table (const hb_face_t *face, hb_tag_t tableTag = Type::tableTag)
{
set_num_glyphs (face->get_num_glyphs ());
return sanitize_blob<Type> (face->reference_table (tableTag));
}

View File

@ -25,8 +25,30 @@
*/
#include "hb-private.hh"
#include "hb-face-private.hh"
#include "hb-open-type-private.hh"
#include "hb-ot-head-table.hh"
#include "hb-ot-maxp-table.hh"
#ifndef HB_NO_VISIBILITY
hb_vector_size_impl_t const _hb_NullPool[(HB_NULL_POOL_SIZE + sizeof (hb_vector_size_impl_t) - 1) / sizeof (hb_vector_size_impl_t)] = {};
/*thread_local*/ hb_vector_size_impl_t _hb_CrapPool[(HB_NULL_POOL_SIZE + sizeof (hb_vector_size_impl_t) - 1) / sizeof (hb_vector_size_impl_t)] = {};
#endif
void
hb_face_t::load_num_glyphs (void) const
{
hb_blob_t *maxp_blob = OT::hb_sanitize_context_t().reference_table<OT::maxp> (this);
const OT::maxp *maxp_table = maxp_blob->as<OT::maxp> ();
num_glyphs = maxp_table->get_num_glyphs ();
hb_blob_destroy (maxp_blob);
}
void
hb_face_t::load_upem (void) const
{
hb_blob_t *head_blob = OT::hb_sanitize_context_t().reference_table<OT::head> (this);
const OT::head *head_table = head_blob->as<OT::head> ();
upem = head_table->get_upem ();
hb_blob_destroy (head_blob);
}