[subset] subset name table step 1, write out table unmodified, use accelerator to access
string
diff --git a/src/hb-ot-name-table.hh b/src/hb-ot-name-table.hh
index fca5091..bacd5a8 100644
--- a/src/hb-ot-name-table.hh
+++ b/src/hb-ot-name-table.hh
@@ -158,6 +158,59 @@
unsigned int get_size () const
{ return min_size + count * nameRecordZ.item_size; }
+ size_t get_subsetted_size(const name *source_name, hb_subset_plan_t *plan, hb_set_t *name_record_ids_to_retain) const
+ {
+ size_t result = min_size;
+ result += count * NameRecord::static_size;
+
+ hb_face_t *face = plan->source;
+ accelerator_t acc;
+ acc.init (face);
+
+ for(unsigned int i = 0; i<count; i++)
+ {
+ result += acc.get_name(i).get_size();
+ if(format == 0 && (unsigned int)nameRecordZ[i].nameID <=25)
+ {
+ name_record_ids_to_retain->add(i);
+ }
+ }
+
+ acc.fini();
+
+ return result;
+ }
+
+ void serialize(void *dest, const void *source, size_t dest_size) const
+ {
+ memcpy(dest, source, dest_size);
+ }
+
+ bool subset(hb_subset_plan_t *plan) const
+ {
+ hb_set_t *name_record_ids_to_retain = hb_set_create();
+ size_t dest_size = get_subsetted_size(this, plan, name_record_ids_to_retain);
+ name *dest = (name *) malloc (dest_size);
+ if(unlikely (!dest))
+ {
+ DEBUG_MSG(SUBSET, nullptr, "Unable to alloc %lu for name subset output.",
+ (unsigned long) dest_size);
+ return false;
+ }
+
+ serialize(dest, this, dest_size);
+ hb_set_destroy(name_record_ids_to_retain);
+
+ hb_blob_t *name_prime_blob = hb_blob_create((const char *) dest,
+ dest_size,
+ HB_MEMORY_MODE_READONLY,
+ dest,
+ free);
+ bool result = plan->add_table (HB_OT_TAG_name, name_prime_blob);
+ hb_blob_destroy (name_prime_blob);
+
+ return result;
+ }
bool sanitize_records (hb_sanitize_context_t *c) const
{
TRACE_SANITIZE (this);
diff --git a/src/hb-subset.cc b/src/hb-subset.cc
index bccb98d..333e7d4 100644
--- a/src/hb-subset.cc
+++ b/src/hb-subset.cc
@@ -43,6 +43,7 @@
#include "hb-ot-cff1-table.hh"
#include "hb-ot-cff2-table.hh"
#include "hb-ot-vorg-table.hh"
+#include "hb-ot-name-table.hh"
#include "hb-ot-layout-gsub-table.hh"
#include "hb-ot-layout-gpos-table.hh"
@@ -158,6 +159,9 @@
case HB_OT_TAG_hdmx:
result = _subset<const OT::hdmx> (plan);
break;
+ case HB_OT_TAG_name:
+ result = _subset<const OT::name> (plan);
+ break;
case HB_OT_TAG_head:
// TODO that won't work well if there is no glyf
DEBUG_MSG(SUBSET, nullptr, "skip head, handled by glyf");