From c6bc7c38314ea831418fdd1434bbe5afc0875f33 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Mon, 23 Jul 2018 11:46:46 -0700 Subject: [PATCH] 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. --- src/hb-face.cc | 20 -------------------- src/hb-open-type-private.hh | 1 + src/hb-static.cc | 22 ++++++++++++++++++++++ 3 files changed, 23 insertions(+), 20 deletions(-) diff --git a/src/hb-face.cc b/src/hb-face.cc index ad44eff59..fab2aa3a9 100644 --- a/src/hb-face.cc +++ b/src/hb-face.cc @@ -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 (this); - const OT::head *head_table = head_blob->as (); - 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 (this); - const OT::maxp *maxp_table = maxp_blob->as (); - num_glyphs = maxp_table->get_num_glyphs (); - hb_blob_destroy (maxp_blob); -} - /** * hb_face_get_table_tags: * @face: a face. diff --git a/src/hb-open-type-private.hh b/src/hb-open-type-private.hh index c59bb6a53..e2a135562 100644 --- a/src/hb-open-type-private.hh +++ b/src/hb-open-type-private.hh @@ -348,6 +348,7 @@ struct hb_sanitize_context_t : template 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 (face->reference_table (tableTag)); } diff --git a/src/hb-static.cc b/src/hb-static.cc index ee17cd348..729b242c5 100644 --- a/src/hb-static.cc +++ b/src/hb-static.cc @@ -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 (this); + const OT::maxp *maxp_table = maxp_blob->as (); + 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 (this); + const OT::head *head_table = head_blob->as (); + upem = head_table->get_upem (); + hb_blob_destroy (head_blob); +}