Add skeleton of hb-subset-glyf, call if from hb_subset(...)

This commit is contained in:
Garret Rieger 2018-02-06 16:04:09 -08:00 committed by Behdad Esfahbod
parent 31ec3c2ec4
commit 6a45e5df24
4 changed files with 100 additions and 2 deletions

View File

@ -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)

45
src/hb-subset-glyf.cc Normal file
View File

@ -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;
}

37
src/hb-subset-glyf.hh Normal file
View File

@ -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 */

View File

@ -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;
}