diff --git a/src/Makefile.sources b/src/Makefile.sources index 0d5af3243..f2821e3de 100644 --- a/src/Makefile.sources +++ b/src/Makefile.sources @@ -184,11 +184,13 @@ HB_ICU_headers = hb-icu.h # Sources for libharfbuzz-subset HB_SUBSET_sources = \ hb-subset.cc \ + hb-subset-glyf.cc \ hb-subset-plan.cc \ $(NULL) HB_SUBSET_headers = \ hb-subset.h \ + hb-subset-glyf.hh \ hb-subset-plan.hh \ hb-subset-private.hh \ $(NULL) diff --git a/src/hb-subset-glyf.cc b/src/hb-subset-glyf.cc new file mode 100644 index 000000000..099f506cf --- /dev/null +++ b/src/hb-subset-glyf.cc @@ -0,0 +1,45 @@ +/* + * Copyright © 2018 Google, Inc. + * + * This is part of HarfBuzz, a text shaping library. + * + * Permission is hereby granted, without written agreement and without + * license or royalty fees, to use, copy, modify, and distribute this + * software and its documentation for any purpose, provided that the + * above copyright notice and the following two paragraphs appear in + * all copies of this software. + * + * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR + * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES + * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN + * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH + * DAMAGE. + * + * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, + * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS + * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO + * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + * + * Google Author(s): Garret Rieger + */ + +#include "hb-subset-glyf.hh" + +/** + * hb_subset_glyf: + * Subsets the glyph table according to a provided plan. + * + * Return value: subsetted glyf table. + * + * Since: 1.7.5 + **/ +bool +hb_subset_glyf (hb_subset_plan_t *plan, + hb_blob_t *glyf, + hb_blob_t **glyf_prime /* OUT */) +{ + *glyf_prime = hb_blob_get_empty (); + + return true; +} diff --git a/src/hb-subset-glyf.hh b/src/hb-subset-glyf.hh new file mode 100644 index 000000000..8bb0d8642 --- /dev/null +++ b/src/hb-subset-glyf.hh @@ -0,0 +1,37 @@ +/* + * Copyright © 2018 Google + * + * This is part of HarfBuzz, a text shaping library. + * + * Permission is hereby granted, without written agreement and without + * license or royalty fees, to use, copy, modify, and distribute this + * software and its documentation for any purpose, provided that the + * above copyright notice and the following two paragraphs appear in + * all copies of this software. + * + * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR + * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES + * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN + * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH + * DAMAGE. + * + * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, + * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS + * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO + * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + * + * Google Author(s): Garret Rieger + */ + +#ifndef HB_SUBSET_GLYF_H +#define HB_SUBSET_GLYF_H + +#include "hb-subset-plan.hh" + +bool +hb_subset_glyf (hb_subset_plan_t *plan, + hb_blob_t *glyf, + hb_blob_t **glyf_prime /* OUT */); + +#endif /* HB_SUBSET_GLYF_HH */ diff --git a/src/hb-subset.cc b/src/hb-subset.cc index 6ae3ed7a2..7b44d5168 100644 --- a/src/hb-subset.cc +++ b/src/hb-subset.cc @@ -27,9 +27,12 @@ #include "hb-object-private.hh" #include "hb-private.hh" +#include "hb-subset-glyf.hh" #include "hb-subset-private.hh" #include "hb-subset-plan.hh" +#include "hb-ot-glyf-table.hh" + struct hb_subset_profile_t { hb_object_header_t header; ASSERT_POD (); @@ -160,8 +163,19 @@ hb_subset (hb_subset_profile_t *profile, // - copy the table into the output. // - Fix header + table directory. - *result = hb_face_reference_blob(face->face); + bool success = true; + hb_blob_t *glyf = hb_face_reference_table (face->face, HB_OT_TAG_glyf); + hb_blob_t *glyf_prime = nullptr; + if (hb_subset_glyf (plan, glyf, &glyf_prime)) { + // TODO: write new glyf to new face. + } else { + success = false; + } + hb_blob_destroy (glyf_prime); + hb_blob_destroy (glyf); + + *result = hb_face_reference_blob(face->face); hb_subset_plan_destroy (plan); - return true; + return success; }