diff --git a/src/hb-ot-post-table.hh b/src/hb-ot-post-table.hh index 9e4792115ea31cd94a42f34b5f5238b6f287bf07..cb1e4eb42488d31bb2c5a7856541b00a74266a6a 100644 --- a/src/hb-ot-post-table.hh +++ b/src/hb-ot-post-table.hh @@ -82,6 +82,34 @@ struct post return_trace (true); } + inline bool subset (hb_subset_plan_t *plan) const + { + hb_blob_t *post_blob = OT::Sanitizer().sanitize (hb_face_reference_table (plan->source, HB_OT_TAG_post)); + post *post_table = (post *) hb_blob_get_data (post_blob, nullptr); + + post *post_prime = (post *) malloc (post::static_size); + if (unlikely (!post_prime)) + { + hb_blob_destroy (post_blob); + DEBUG_MSG(SUBSET, nullptr, "Unable to alloc %lu for post subset output.", (unsigned long) post::static_size); + return false; + } + + memcpy (post_prime, post_table, post::static_size); + hb_blob_destroy (post_blob); + + post_prime->version.major.set (3); // Version 3 does not have any glyph names. + hb_blob_t *post_prime_blob = hb_blob_create ((const char *) post_prime, + post::static_size, + HB_MEMORY_MODE_READONLY, + post_prime, + free); + bool result = hb_subset_plan_add_table (plan, HB_OT_TAG_post, post_prime_blob); + hb_blob_destroy (post_prime_blob); + + return result; + } + struct accelerator_t { inline void init (hb_face_t *face) diff --git a/src/hb-subset.cc b/src/hb-subset.cc index 541987bf5b3daa0bbf62d371d87704f278a76cd4..77f60db1d18358a482fb00fda6928c08697cddef 100644 --- a/src/hb-subset.cc +++ b/src/hb-subset.cc @@ -41,6 +41,7 @@ #include "hb-ot-hmtx-table.hh" #include "hb-ot-maxp-table.hh" #include "hb-ot-os2-table.hh" +#include "hb-ot-post-table.hh" #ifndef HB_NO_VISIBILITY @@ -270,6 +271,9 @@ _subset_table (hb_subset_plan_t *plan, case HB_OT_TAG_os2: result = _subset (plan); break; + case HB_OT_TAG_post: + result = _subset (plan); + break; default: hb_blob_t *source_table = hb_face_reference_table(plan->source, tag); if (likely (source_table))