diff --git a/src/hb-ot-cmap-table.hh b/src/hb-ot-cmap-table.hh index 570f13408..219eca7b2 100644 --- a/src/hb-ot-cmap-table.hh +++ b/src/hb-ot-cmap-table.hh @@ -504,8 +504,13 @@ struct cmap encodingRecord.sanitize (c, this)); } - inline bool subset(hb_subset_plan_t *plan, OT::hb_serialize_context_t *out) const + inline bool subset(hb_subset_plan_t *plan, hb_face_t *source, hb_face_t *dest) const { + // TODO something useful re: memory, write to dest + size_t dest_sz = 64536; // as much as anyone would ever need + void *dest_buf = malloc(dest_sz); + OT::hb_serialize_context_t context(dest_buf, dest_sz); + // Same version OT::cmap new_cmap; new_cmap.version = version; diff --git a/src/hb-subset.cc b/src/hb-subset.cc index 9c1d6d43e..bd4e34f61 100644 --- a/src/hb-subset.cc +++ b/src/hb-subset.cc @@ -109,22 +109,21 @@ hb_subset_input_destroy(hb_subset_input_t *subset_input) template hb_bool_t -subset(hb_subset_plan_t *plan, hb_face_t *face, hb_blob_t **out) +subset(hb_subset_plan_t *plan, hb_face_t *source, hb_face_t *dest) { OT::Sanitizer sanitizer; - hb_blob_t *table_blob = sanitizer.sanitize (face->reference_table (TableType::tableTag)); + hb_blob_t *table_blob = sanitizer.sanitize (source->reference_table (TableType::tableTag)); if (unlikely(!table_blob)) { + DEBUG_MSG(SUBSET, nullptr, "Failed to reference table for tag %d", TableType::tableTag); return false; } const TableType *table = OT::Sanitizer::lock_instance (table_blob); - - // TODO actually manage the context/output memory - size_t dest_sz = 64536; // as much as anyone would ever need - void *dest = malloc(dest_sz); - OT::hb_serialize_context_t context(dest, dest_sz); - hb_bool_t result = table->subset(plan, &context); - // TODO populate out + hb_bool_t result = table->subset(plan, source, dest); + hb_blob_destroy (table_blob); + + // TODO string not numeric tag + DEBUG_MSG(SUBSET, nullptr, "Subset %d %s", TableType::tableTag, result ? "success" : "FAILED!"); return result; } @@ -306,18 +305,17 @@ hb_subset (hb_face_t *source, // - copy the table into the output. // - Fix header + table directory. + bool success = true; + + hb_face_t *dest = nullptr; // TODO allocate dest + hb_blob_t *glyf_prime = nullptr; if (hb_subset_glyf (plan, source, &glyf_prime)) { // TODO: write new glyf to new face. } hb_blob_destroy (glyf_prime); - hb_blob_t *cmap_prime = nullptr; - if (subset(plan, source, &cmap_prime)) { - DEBUG_MSG(SUBSET, nullptr, "subset cmap success!"); - } else { - DEBUG_MSG(SUBSET, nullptr, "subset cmap FAILED!"); - } + success = success && subset(plan, source, dest); hb_subset_plan_destroy (plan);