From 7481f0ce21489d2b19b2e33d05358736ddee20bf Mon Sep 17 00:00:00 2001 From: Garret Rieger Date: Mon, 5 Feb 2018 16:05:12 -0800 Subject: [PATCH] Add codepoints to subset input. --- src/hb-subset.cc | 24 ++++++++++++++++-------- src/hb-subset.h | 2 +- test/api/test-subset.c | 2 +- util/hb-subset.cc | 2 +- 4 files changed, 19 insertions(+), 11 deletions(-) diff --git a/src/hb-subset.cc b/src/hb-subset.cc index 62f7f0ad..f56217f6 100644 --- a/src/hb-subset.cc +++ b/src/hb-subset.cc @@ -38,6 +38,8 @@ struct hb_subset_profile_t { struct hb_subset_input_t { hb_object_header_t header; ASSERT_POD (); + + hb_set_t *codepoints; }; struct hb_subset_face_t { @@ -82,9 +84,14 @@ hb_subset_profile_destroy (hb_subset_profile_t *profile) * Since: 1.7.5 **/ hb_subset_input_t * -hb_subset_input_create() +hb_subset_input_create (hb_set_t *codepoints) { - return hb_object_create(); + if (unlikely (!codepoints)) + codepoints = hb_set_get_empty(); + + hb_subset_input_t *input = hb_object_create(); + input->codepoints = hb_set_reference(codepoints); + return input; } /** @@ -97,6 +104,7 @@ hb_subset_input_destroy(hb_subset_input_t *subset_input) { if (!hb_object_destroy (subset_input)) return; + hb_set_destroy (subset_input->codepoints); free (subset_input); } @@ -108,7 +116,7 @@ hb_subset_input_destroy(hb_subset_input_t *subset_input) * Since: 1.7.5 **/ hb_subset_face_t * -hb_subset_face_create(hb_face_t *face) +hb_subset_face_create (hb_face_t *face) { if (unlikely (!face)) face = hb_face_get_empty(); @@ -125,7 +133,7 @@ hb_subset_face_create(hb_face_t *face) * Since: 1.7.5 **/ void -hb_subset_face_destroy(hb_subset_face_t *subset_face) +hb_subset_face_destroy (hb_subset_face_t *subset_face) { if (!hb_object_destroy (subset_face)) return; @@ -143,10 +151,10 @@ hb_subset_face_destroy(hb_subset_face_t *subset_face) * Subsets a font according to provided profile and input. **/ hb_bool_t -hb_subset(hb_subset_profile_t *profile, - hb_subset_input_t *input, - hb_subset_face_t *face, - hb_blob_t **result /* OUT */) +hb_subset (hb_subset_profile_t *profile, + hb_subset_input_t *input, + hb_subset_face_t *face, + hb_blob_t **result /* OUT */) { if (!profile || !input || !face) return false; diff --git a/src/hb-subset.h b/src/hb-subset.h index 969cf5d2..47127e03 100644 --- a/src/hb-subset.h +++ b/src/hb-subset.h @@ -53,7 +53,7 @@ hb_subset_profile_destroy (hb_subset_profile_t *profile); typedef struct hb_subset_input_t hb_subset_input_t; HB_EXTERN hb_subset_input_t * -hb_subset_input_create (); +hb_subset_input_create (hb_set_t *codepoints); HB_EXTERN void hb_subset_input_destroy (hb_subset_input_t *subset_input); diff --git a/test/api/test-subset.c b/test/api/test-subset.c index 33a1ef29..4841af62 100644 --- a/test/api/test-subset.c +++ b/test/api/test-subset.c @@ -42,7 +42,7 @@ test_subset (void) hb_face_t *face = hb_face_create(font_blob, 0); hb_subset_profile_t *profile = hb_subset_profile_create(); - hb_subset_input_t *input = hb_subset_input_create(); + hb_subset_input_t *input = hb_subset_input_create (hb_set_get_empty ()); hb_subset_face_t *subset_face = hb_subset_face_create(face); hb_blob_t *output; diff --git a/util/hb-subset.cc b/util/hb-subset.cc index 27398ab0..2ec0efe3 100644 --- a/util/hb-subset.cc +++ b/util/hb-subset.cc @@ -80,7 +80,7 @@ struct subset_consumer_t { // TODO(Q1) check for errors from creates and such hb_subset_profile_t *subset_profile = hb_subset_profile_create(); - hb_subset_input_t *subset_input = hb_subset_input_create(); + hb_subset_input_t *subset_input = hb_subset_input_create (hb_set_get_empty ()); hb_face_t *face = hb_font_get_face (font); hb_subset_face_t *subset_face = hb_subset_face_create(face); -- GitLab