From dd107699938740e261948e4b525fa0ad501beb03 Mon Sep 17 00:00:00 2001 From: Garret Rieger Date: Tue, 6 Mar 2018 18:33:39 -0800 Subject: [PATCH] [subset] drop all glyph names from the post table. --- src/hb-ot-post-table.hh | 28 ++++++++++++++++++++++++++++ src/hb-subset.cc | 4 ++++ 2 files changed, 32 insertions(+) diff --git a/src/hb-ot-post-table.hh b/src/hb-ot-post-table.hh index 9e4792115..cb1e4eb42 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 541987bf5..77f60db1d 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))