Update interface to hb-subset-glyf to subset glyf and loca.
authorGarret Rieger <grieger@google.com>
Thu, 8 Feb 2018 00:53:18 +0000 (16:53 -0800)
committerBehdad Esfahbod <behdad@behdad.org>
Thu, 8 Feb 2018 23:31:11 +0000 (17:31 -0600)
src/hb-subset-glyf.cc
src/hb-subset-glyf.hh
src/hb-subset.cc

index 2425645..bbd74d7 100644 (file)
@@ -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<OT::glyf>().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;
 }
index fd217e7..c802da2 100644 (file)
@@ -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 */
index bd4e34f..f10f35b 100644 (file)
@@ -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);