From f9c665fed1347f7af6d36ba129f9d174f4ac54dc Mon Sep 17 00:00:00 2001 From: Garret Rieger Date: Wed, 7 Feb 2018 16:53:18 -0800 Subject: [PATCH] Update interface to hb-subset-glyf to subset glyf and loca. --- src/hb-subset-glyf.cc | 10 +++++++--- src/hb-subset-glyf.hh | 7 ++++--- src/hb-subset.cc | 7 +++++-- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/hb-subset-glyf.cc b/src/hb-subset-glyf.cc index 24256454f..bbd74d7ec 100644 --- a/src/hb-subset-glyf.cc +++ b/src/hb-subset-glyf.cc @@ -83,6 +83,7 @@ _hb_subset_glyf (const OT::glyf::accelerator_t &glyf, // TODO(grieger): Sanity check writes to make sure they are in-bounds. // TODO(grieger): Sanity check allocation size for the new table. // TODO(grieger): Subset loca simultaneously. + // TODO(grieger): Don't fail on bad offsets, just dump them. unsigned int glyf_prime_size; if (unlikely (!_calculate_glyf_prime_size (glyf, @@ -115,9 +116,10 @@ _hb_subset_glyf (const OT::glyf::accelerator_t &glyf, * Since: 1.7.5 **/ bool -hb_subset_glyf (hb_subset_plan_t *plan, - hb_face_t *face, - hb_blob_t **glyf_prime /* OUT */) +hb_subset_glyf_and_loca (hb_subset_plan_t *plan, + hb_face_t *face, + hb_blob_t **glyf_prime /* OUT */, + hb_blob_t **loca_prime /* OUT */) { hb_blob_t *glyf_blob = OT::Sanitizer().sanitize (face->reference_table (HB_OT_TAG_glyf)); const char *glyf_data = hb_blob_get_data(glyf_blob, nullptr); @@ -127,5 +129,7 @@ hb_subset_glyf (hb_subset_plan_t *plan, bool result = _hb_subset_glyf (glyf, glyf_data, plan->glyphs_to_retain, glyf_prime); glyf.fini(); + // TODO(grieger): Subset loca + return result; } diff --git a/src/hb-subset-glyf.hh b/src/hb-subset-glyf.hh index fd217e79c..c802da249 100644 --- a/src/hb-subset-glyf.hh +++ b/src/hb-subset-glyf.hh @@ -30,8 +30,9 @@ #include "hb-subset-plan.hh" bool -hb_subset_glyf (hb_subset_plan_t *plan, - hb_face_t *face, - hb_blob_t **glyf_prime /* OUT */); +hb_subset_glyf_and_loca (hb_subset_plan_t *plan, + hb_face_t *face, + hb_blob_t **glyf_prime /* OUT */, + hb_blob_t **loca_prime /* OUT */); #endif /* HB_SUBSET_GLYF_HH */ diff --git a/src/hb-subset.cc b/src/hb-subset.cc index bd4e34f61..f10f35ba4 100644 --- a/src/hb-subset.cc +++ b/src/hb-subset.cc @@ -310,8 +310,11 @@ hb_subset (hb_face_t *source, 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_t *loca_prime = nullptr; + if (hb_subset_glyf_and_loca (plan, source, &glyf_prime, &loca_prime)) { + // TODO: write new glyf and loca to new face. + } else { + success = false; } hb_blob_destroy (glyf_prime);