From 973c47f6c9886cd2a50d29e09c978831b4e355f6 Mon Sep 17 00:00:00 2001 From: Qunxin Liu Date: Thu, 11 Jun 2020 11:27:57 -0700 Subject: [PATCH] [subset] Move 2 experimental public api methods to be private methods in GSUB/GPOS. 2 methods are: hb_ot_layout_closure_lookups and hb_ot_layout_closure_features --- docs/harfbuzz-sections.txt | 2 - src/gen-def.py | 4 +- src/hb-ot-layout-gpos-table.hh | 5 +++ src/hb-ot-layout-gsub-table.hh | 5 +++ src/hb-ot-layout-gsubgpos.hh | 15 +++++++ src/hb-ot-layout.cc | 66 ------------------------------- src/hb-ot-layout.h | 14 ------- src/hb-subset-plan.cc | 35 ++++++---------- test/api/test-ot-face.c | 6 --- test/subset/data/Makefile.sources | 3 -- test/subset/meson.build | 5 --- 11 files changed, 39 insertions(+), 121 deletions(-) diff --git a/docs/harfbuzz-sections.txt b/docs/harfbuzz-sections.txt index bcad37a77..38b357dd1 100644 --- a/docs/harfbuzz-sections.txt +++ b/docs/harfbuzz-sections.txt @@ -552,8 +552,6 @@ HB_OT_TAG_GPOS HB_OT_TAG_GSUB HB_OT_TAG_JSTF hb_ot_layout_baseline_tag_t -hb_ot_layout_closure_lookups -hb_ot_layout_closure_features hb_ot_layout_collect_lookups hb_ot_layout_collect_features hb_ot_layout_feature_get_characters diff --git a/src/gen-def.py b/src/gen-def.py index 1ff3f48a8..822a9448d 100755 --- a/src/gen-def.py +++ b/src/gen-def.py @@ -37,9 +37,7 @@ hb_draw_funcs_set_line_to_func hb_draw_funcs_set_move_to_func hb_draw_funcs_set_quadratic_to_func hb_style_get_value -hb_font_get_var_coords_design -hb_ot_layout_closure_lookups -hb_ot_layout_closure_features""".splitlines () +hb_font_get_var_coords_design""".splitlines () symbols = [x for x in symbols if x not in experimental_symbols] symbols = "\n".join (symbols) diff --git a/src/hb-ot-layout-gpos-table.hh b/src/hb-ot-layout-gpos-table.hh index c22a802b0..5fd848fe6 100644 --- a/src/hb-ot-layout-gpos-table.hh +++ b/src/hb-ot-layout-gpos-table.hh @@ -2572,6 +2572,11 @@ struct GPOS : GSUBGPOS } } + void closure_lookups (hb_face_t *face, + const hb_set_t *glyphs, + hb_set_t *lookup_indexes /* IN/OUT */) const + { GSUBGPOS::closure_lookups (face, glyphs, lookup_indexes); } + typedef GSUBGPOS::accelerator_t accelerator_t; }; diff --git a/src/hb-ot-layout-gsub-table.hh b/src/hb-ot-layout-gsub-table.hh index 217bce8dd..612720e64 100644 --- a/src/hb-ot-layout-gsub-table.hh +++ b/src/hb-ot-layout-gsub-table.hh @@ -1550,6 +1550,11 @@ struct GSUB : GSUBGPOS HB_INTERNAL bool is_blocklisted (hb_blob_t *blob, hb_face_t *face) const; + void closure_lookups (hb_face_t *face, + const hb_set_t *glyphs, + hb_set_t *lookup_indexes /* IN/OUT */) const + { GSUBGPOS::closure_lookups (face, glyphs, lookup_indexes); } + typedef GSUBGPOS::accelerator_t accelerator_t; }; diff --git a/src/hb-ot-layout-gsubgpos.hh b/src/hb-ot-layout-gsubgpos.hh index e2c24f207..0026f83a5 100644 --- a/src/hb-ot-layout-gsubgpos.hh +++ b/src/hb-ot-layout-gsubgpos.hh @@ -3276,6 +3276,21 @@ struct GSUBGPOS #endif } + template + void closure_lookups (hb_face_t *face, + const hb_set_t *glyphs, + hb_set_t *lookup_indexes /* IN/OUT */) const + { + hb_set_t visited_lookups, inactive_lookups; + OT::hb_closure_lookups_context_t c (face, glyphs, &visited_lookups, &inactive_lookups); + + for (unsigned lookup_index : + hb_iter (lookup_indexes)) + reinterpret_cast (get_lookup (lookup_index)).closure_lookups (&c, lookup_index); + + hb_set_union (lookup_indexes, &visited_lookups); + hb_set_subtract (lookup_indexes, &inactive_lookups); + } + template bool subset (hb_subset_layout_context_t *c) const { diff --git a/src/hb-ot-layout.cc b/src/hb-ot-layout.cc index 3ce1bfbdf..c57cea671 100644 --- a/src/hb-ot-layout.cc +++ b/src/hb-ot-layout.cc @@ -1202,72 +1202,6 @@ hb_ot_layout_collect_lookups (hb_face_t *face, g.feature_variation_collect_lookups (&feature_indexes, lookup_indexes); } -#ifdef HB_EXPERIMENTAL_API -/** - * hb_ot_layout_closure_lookups: - * @face: #hb_face_t to work upon - * @table_tag: HB_OT_TAG_GSUB or HB_OT_TAG_GPOS - * @lookup_indexes: (inout): lookup_indices collected from feature - * list - * - * Returns all inactive lookups reachable from lookup_indices - * - * Since: EXPERIMENTAL - **/ -void -hb_ot_layout_closure_lookups (hb_face_t *face, - hb_tag_t table_tag, - const hb_set_t *glyphs, - hb_set_t *lookup_indexes /* IN/OUT */) -{ - hb_set_t visited_lookups, inactive_lookups; - OT::hb_closure_lookups_context_t c (face, glyphs, &visited_lookups, &inactive_lookups); - - for (unsigned lookup_index : + hb_iter (lookup_indexes)) - { - switch (table_tag) - { - case HB_OT_TAG_GSUB: - { - const OT::SubstLookup& l = face->table.GSUB->table->get_lookup (lookup_index); - l.closure_lookups (&c, lookup_index); - break; - } - case HB_OT_TAG_GPOS: - { - const OT::PosLookup& l = face->table.GPOS->table->get_lookup (lookup_index); - l.closure_lookups (&c, lookup_index); - break; - } - } - } - - hb_set_union (lookup_indexes, &visited_lookups); - hb_set_subtract (lookup_indexes, &inactive_lookups); -} - -/** - * hb_ot_layout_closure_features: - * @face: #hb_face_t to work upon - * @table_tag: HB_OT_TAG_GSUB or HB_OT_TAG_GPOS - * @lookup_indexes: (in): collected active lookup_indices - * @feature_indexes: (out): all active feature indexes collected - * - * Returns all active feature indexes - * - * Since: EXPERIMENTAL - **/ -void -hb_ot_layout_closure_features (hb_face_t *face, - hb_tag_t table_tag, - const hb_map_t *lookup_indexes, /* IN */ - hb_set_t *feature_indexes /* OUT */) -{ - const OT::GSUBGPOS &g = get_gsubgpos_table (face, table_tag); - g.closure_features (lookup_indexes, feature_indexes); -} -#endif - #ifndef HB_NO_LAYOUT_COLLECT_GLYPHS /** diff --git a/src/hb-ot-layout.h b/src/hb-ot-layout.h index 6255a9173..363dea89c 100644 --- a/src/hb-ot-layout.h +++ b/src/hb-ot-layout.h @@ -262,20 +262,6 @@ hb_ot_layout_collect_lookups (hb_face_t *face, const hb_tag_t *features, hb_set_t *lookup_indexes /* OUT */); -#ifdef HB_EXPERIMENTAL_API -HB_EXTERN void -hb_ot_layout_closure_lookups (hb_face_t *face, - hb_tag_t table_tag, - const hb_set_t *glyphs, - hb_set_t *lookup_indexes /* IN/OUT */); - -HB_EXTERN void -hb_ot_layout_closure_features (hb_face_t *face, - hb_tag_t table_tag, - const hb_map_t *lookup_indexes, /* IN */ - hb_set_t *feature_indexes /* OUT */); -#endif - HB_EXTERN void hb_ot_layout_lookup_collect_glyphs (hb_face_t *face, hb_tag_t table_tag, diff --git a/src/hb-subset-plan.cc b/src/hb-subset-plan.cc index 9a5d74b64..b16f5077c 100644 --- a/src/hb-subset-plan.cc +++ b/src/hb-subset-plan.cc @@ -32,6 +32,7 @@ #include "hb-ot-glyf-table.hh" #include "hb-ot-layout-gdef-table.hh" #include "hb-ot-layout-gpos-table.hh" +#include "hb-ot-layout-gsub-table.hh" #include "hb-ot-cff1-table.hh" #include "hb-ot-color-colr-table.hh" #include "hb-ot-var-fvar-table.hh" @@ -54,7 +55,6 @@ _add_cff_seac_components (const OT::cff1::accelerator_t &cff, #endif #ifndef HB_NO_SUBSET_LAYOUT -#ifdef HB_EXPERIMENTAL_API static void _remap_indexes (const hb_set_t *indexes, hb_map_t *mapping /* OUT */) @@ -65,7 +65,6 @@ _remap_indexes (const hb_set_t *indexes, mapping->set (_.first, _.second); } -#endif static inline void _gsub_closure_glyphs_lookups_features (hb_face_t *face, @@ -83,21 +82,17 @@ _gsub_closure_glyphs_lookups_features (hb_face_t *face, hb_ot_layout_lookups_substitute_closure (face, &lookup_indices, gids_to_retain); -#ifdef HB_EXPERIMENTAL_API - hb_ot_layout_closure_lookups (face, - HB_OT_TAG_GSUB, - gids_to_retain, - &lookup_indices); + hb_blob_ptr_t gsub = hb_sanitize_context_t ().reference_table (face); + gsub->closure_lookups (face, + gids_to_retain, + &lookup_indices); _remap_indexes (&lookup_indices, gsub_lookups); //closure features hb_set_t feature_indices; - hb_ot_layout_closure_features (face, - HB_OT_TAG_GSUB, - gsub_lookups, - &feature_indices); + gsub->closure_features (gsub_lookups, &feature_indices); _remap_indexes (&feature_indices, gsub_features); -#endif + gsub.destroy (); } static inline void @@ -113,21 +108,17 @@ _gpos_closure_lookups_features (hb_face_t *face, nullptr, nullptr, &lookup_indices); -#ifdef HB_EXPERIMENTAL_API - hb_ot_layout_closure_lookups (face, - HB_OT_TAG_GPOS, - gids_to_retain, - &lookup_indices); + hb_blob_ptr_t gpos = hb_sanitize_context_t ().reference_table (face); + gpos->closure_lookups (face, + gids_to_retain, + &lookup_indices); _remap_indexes (&lookup_indices, gpos_lookups); //closure features hb_set_t feature_indices; - hb_ot_layout_closure_features (face, - HB_OT_TAG_GPOS, - gpos_lookups, - &feature_indices); + gpos->closure_features (gpos_lookups, &feature_indices); _remap_indexes (&feature_indices, gpos_features); -#endif + gpos.destroy (); } #endif diff --git a/test/api/test-ot-face.c b/test/api/test-ot-face.c index fb31ed2b8..0596e4baf 100644 --- a/test/api/test-ot-face.c +++ b/test/api/test-ot-face.c @@ -85,16 +85,10 @@ test_font (hb_font_t *font, hb_codepoint_t cp) hb_set_t *lookup_indexes = hb_set_create (); hb_set_add (lookup_indexes, 0); -#ifdef HB_EXPERIMENTAL_API - hb_ot_layout_closure_lookups (face, HB_OT_TAG_GSUB, set, lookup_indexes); -#endif hb_map_t *lookup_mapping = hb_map_create (); hb_map_set (lookup_mapping, 0, 0); hb_set_t *feature_indices = hb_set_create (); -#ifdef HB_EXPERIMENTAL_API - hb_ot_layout_closure_features (face, HB_OT_TAG_GSUB, lookup_mapping, feature_indices); -#endif hb_set_destroy (lookup_indexes); hb_set_destroy (feature_indices); hb_map_destroy (lookup_mapping); diff --git a/test/subset/data/Makefile.sources b/test/subset/data/Makefile.sources index a6b8659f2..e3e254766 100644 --- a/test/subset/data/Makefile.sources +++ b/test/subset/data/Makefile.sources @@ -9,9 +9,6 @@ TESTS = \ tests/sbix.tests \ tests/colr.tests \ tests/cbdt.tests \ - $(NULL) - -DISABLED_TESTS = \ tests/layout.tests \ tests/layout.gpos.tests \ tests/layout.gpos2.tests \ diff --git a/test/subset/meson.build b/test/subset/meson.build index 525cd890c..0dc2c59e8 100644 --- a/test/subset/meson.build +++ b/test/subset/meson.build @@ -29,11 +29,6 @@ run_test = find_program('run-tests.py') foreach t : tests fname = '@0@.tests'.format(t) - # layout test are enabled only under experimental API flag for now - if t.contains('layout') and not get_option('experimental_api') - continue - endif - test(t, run_test, args: [ hb_subset,