From dae39c58fb63c2211e2842121bbe6d5b8b18651b Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Sat, 25 Aug 2018 22:44:39 -0700 Subject: [PATCH] [face] Introduce character-map API New API: +hb_face_collect_unicodes +hb_face_collect_variation_selectors +hb_face_collect_variation_unicodes --- docs/harfbuzz-sections.txt | 3 + src/hb-face.cc | 61 ++++++++++++++++++- src/hb-face.h | 19 ++++++ src/hb-subset.cc | 53 ---------------- src/hb-subset.h | 15 ----- test/api/test-subset-codepoints.c | 6 +- .../hb-subset-get-codepoints-fuzzer.cc | 2 +- 7 files changed, 86 insertions(+), 73 deletions(-) diff --git a/docs/harfbuzz-sections.txt b/docs/harfbuzz-sections.txt index 043611e9..ca0e908f 100644 --- a/docs/harfbuzz-sections.txt +++ b/docs/harfbuzz-sections.txt @@ -189,6 +189,9 @@ hb_face_set_glyph_count hb_face_set_index hb_face_set_upem hb_face_set_user_data +hb_face_collect_unicodes +hb_face_collect_variation_selectors +hb_face_collect_variation_unicodes hb_face_builder_create hb_face_builder_add_table diff --git a/src/hb-face.cc b/src/hb-face.cc index b3956c45..286b1f2c 100644 --- a/src/hb-face.cc +++ b/src/hb-face.cc @@ -31,6 +31,7 @@ #include "hb-face.hh" #include "hb-blob.hh" #include "hb-open-file.hh" +#include "hb-ot-cmap-table.hh" /** @@ -514,6 +515,65 @@ hb_face_get_table_tags (const hb_face_t *face, } +/* + * Character set. + */ + +/** + * hb_face_collect_unicodes: + * @face: font face. + * @out: set to add Unicode characters covered by @face to. + * + * Since: REPLACEME + */ +void +hb_face_collect_unicodes (hb_face_t *face, + hb_set_t *out) +{ + /* XXX Use saved accel. */ + hb_auto_t cmap (face); + cmap.collect_unicodes (out); +} + +/** + * hb_face_collect_variation_selectors: + * @face: font face. + * @out: set to add Variation Selector characters covered by @face to. + * + * + * + * Since: REPLACEME + */ +void +hb_face_collect_variation_selectors (hb_face_t *face, + hb_set_t *out) +{ + /* XXX Use saved accel. */ + hb_auto_t cmap (face); + cmap.collect_variation_selectors (out); +} + +/** + * hb_face_collect_variation_unicodes: + * @face: font face. + * @out: set to add Unicode characters for @variation_selector covered by @face to. + * + * + * + * Since: REPLACEME + */ +void +hb_face_collect_variation_unicodes (hb_face_t *face, + hb_codepoint_t variation_selector, + hb_set_t *out) +{ + /* XXX Use saved accel. */ + hb_auto_t cmap (face); + cmap.collect_variation_unicodes (variation_selector, out); +} + + + /* * face-builder: A face that has add_table(). */ @@ -660,4 +720,3 @@ hb_face_builder_add_table (hb_face_t *face, hb_tag_t tag, hb_blob_t *blob) return true; } - diff --git a/src/hb-face.h b/src/hb-face.h index 2bc3e895..e8ff090d 100644 --- a/src/hb-face.h +++ b/src/hb-face.h @@ -33,6 +33,7 @@ #include "hb-common.h" #include "hb-blob.h" +#include "hb-set.h" HB_BEGIN_DECLS @@ -121,6 +122,24 @@ hb_face_get_table_tags (const hb_face_t *face, hb_tag_t *table_tags /* OUT */); +/* + * Character set. + */ + +HB_EXTERN void +hb_face_collect_unicodes (hb_face_t *face, + hb_set_t *out); + +HB_EXTERN void +hb_face_collect_variation_selectors (hb_face_t *face, + hb_set_t *out); + +HB_EXTERN void +hb_face_collect_variation_unicodes (hb_face_t *face, + hb_codepoint_t variation_selector, + hb_set_t *out); + + /* * Builder face. */ diff --git a/src/hb-subset.cc b/src/hb-subset.cc index ad8a1106..1ba16059 100644 --- a/src/hb-subset.cc +++ b/src/hb-subset.cc @@ -235,56 +235,3 @@ hb_subset (hb_face_t *source, hb_subset_plan_destroy (plan); return result; } - -/** - * hb_subset_collect_unicodes: - * @face: font face. - * @out: set to add Unicode characters covered by @face to. - * - * Since: REPLACEME - */ -void -hb_subset_collect_unicodes (hb_face_t *face, hb_set_t *out) -{ - /* XXX Use saved accel. */ - hb_auto_t cmap (face); - cmap.collect_unicodes (out); -} - -/** - * hb_subset_collect_variation_selectors: - * @face: font face. - * @out: set to add Variation Selector characters covered by @face to. - * - * - * - * Since: REPLACEME - */ -void -hb_subset_collect_variation_selectors (hb_face_t *face, - hb_set_t *out) -{ - /* XXX Use saved accel. */ - hb_auto_t cmap (face); - cmap.collect_variation_selectors (out); -} - -/** - * hb_subset_collect_variation_unicodes: - * @face: font face. - * @out: set to add Unicode characters for @variation_selector covered by @face to. - * - * - * - * Since: REPLACEME - */ -void -hb_subset_collect_variation_unicodes (hb_face_t *face, - hb_codepoint_t variation_selector, - hb_set_t *out) -{ - /* XXX Use saved accel. */ - hb_auto_t cmap (face); - cmap.collect_variation_unicodes (variation_selector, out); -} - diff --git a/src/hb-subset.h b/src/hb-subset.h index 1e7d8f52..8b7fcc6c 100644 --- a/src/hb-subset.h +++ b/src/hb-subset.h @@ -81,21 +81,6 @@ hb_subset (hb_face_t *source, hb_subset_input_t *input); -/* TODO Move to hb-face.h. */ - -HB_EXTERN void -hb_subset_collect_unicodes (hb_face_t *face, hb_set_t *out); - -HB_EXTERN void -hb_subset_collect_variation_selectors (hb_face_t *face, - hb_set_t *out); - -HB_EXTERN void -hb_subset_collect_variation_unicodes (hb_face_t *face, - hb_codepoint_t variation_selector, - hb_set_t *out); - - HB_END_DECLS #endif /* HB_SUBSET_H */ diff --git a/test/api/test-subset-codepoints.c b/test/api/test-subset-codepoints.c index a2c40cd6..affe9314 100644 --- a/test/api/test-subset-codepoints.c +++ b/test/api/test-subset-codepoints.c @@ -33,7 +33,7 @@ test_collect_unicodes_format4 (void) hb_face_t *face = hb_subset_test_open_font("fonts/Roboto-Regular.abc.format4.ttf"); hb_set_t *codepoints = hb_set_create(); - hb_subset_collect_unicodes (face, codepoints); + hb_face_collect_unicodes (face, codepoints); hb_codepoint_t cp = HB_SET_VALUE_INVALID; g_assert (hb_set_next (codepoints, &cp)); @@ -54,7 +54,7 @@ test_collect_unicodes_format12 (void) hb_face_t *face = hb_subset_test_open_font("fonts/Roboto-Regular.abc.format12.ttf"); hb_set_t *codepoints = hb_set_create(); - hb_subset_collect_unicodes (face, codepoints); + hb_face_collect_unicodes (face, codepoints); hb_codepoint_t cp = HB_SET_VALUE_INVALID; g_assert (hb_set_next (codepoints, &cp)); @@ -75,7 +75,7 @@ test_collect_unicodes (void) hb_face_t *face = hb_subset_test_open_font("fonts/Roboto-Regular.abc.ttf"); hb_set_t *codepoints = hb_set_create(); - hb_subset_collect_unicodes (face, codepoints); + hb_face_collect_unicodes (face, codepoints); hb_codepoint_t cp = HB_SET_VALUE_INVALID; g_assert (hb_set_next (codepoints, &cp)); diff --git a/test/fuzzing/hb-subset-get-codepoints-fuzzer.cc b/test/fuzzing/hb-subset-get-codepoints-fuzzer.cc index bcdafebd..3d43627b 100644 --- a/test/fuzzing/hb-subset-get-codepoints-fuzzer.cc +++ b/test/fuzzing/hb-subset-get-codepoints-fuzzer.cc @@ -13,7 +13,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) hb_face_t *face = hb_face_create (blob, 0); hb_set_t *output = hb_set_create(); - hb_subset_collect_unicodes (face, output); + hb_face_collect_unicodes (face, output); hb_set_destroy (output); hb_face_destroy (face); -- GitLab