From 5bf964a211af0ff32411a5d7afe93dfe809a124f Mon Sep 17 00:00:00 2001 From: Skef Iterum Date: Thu, 3 Apr 2025 15:38:57 -0700 Subject: [PATCH] Finishing up draft --- meson.build | 4 ++++ meson_options.txt | 2 ++ src/OT/Color/COLR/COLR.hh | 2 ++ src/OT/Layout/GSUB/ReverseChainSingleSubstFormat1.hh | 12 ++++++++++-- src/hb-depend-data.hh | 2 +- src/hb-depend.cc | 3 +++ 6 files changed, 22 insertions(+), 3 deletions(-) diff --git a/meson.build b/meson.build index 97ae4ce1b..910987c89 100644 --- a/meson.build +++ b/meson.build @@ -273,6 +273,10 @@ if not get_option('subset').disabled() conf.set('HAVE_SUBSET', 1) endif +if get_option('depend_api') + conf.set('HB_DEPEND_API', 1) +endif + if freetype_dep.found() conf.set('HAVE_FREETYPE', 1) check_freetype_funcs = [ diff --git a/meson_options.txt b/meson_options.txt index 3feffeab7..4e1f50b3b 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -64,6 +64,8 @@ option('with_libstdcxx', type: 'boolean', value: false, description: 'Allow linking with libstdc++') option('experimental_api', type: 'boolean', value: false, description: 'Enable experimental APIs') +option('depend_api', type: 'boolean', value: false, + description: 'Enable dependency analysis APIs') option('ragel_subproject', type: 'boolean', value: false, description: 'Build Ragel subproject if no suitable version is found') option('fuzzer_ldflags', type: 'string', diff --git a/src/OT/Color/COLR/COLR.hh b/src/OT/Color/COLR/COLR.hh index 48e3ec371..e4cbf4454 100644 --- a/src/OT/Color/COLR/COLR.hh +++ b/src/OT/Color/COLR/COLR.hh @@ -2401,6 +2401,7 @@ struct COLR mutable hb_atomic_t cached_scratch; }; +#ifdef HB_DEPEND_API void depend (hb_depend_data_t *depend_data) const { // v0 @@ -2425,6 +2426,7 @@ struct COLR paint.dispatch (&c); } } +#endif void closure_glyphs (hb_codepoint_t glyph, hb_set_t *related_ids /* OUT */) const diff --git a/src/OT/Layout/GSUB/ReverseChainSingleSubstFormat1.hh b/src/OT/Layout/GSUB/ReverseChainSingleSubstFormat1.hh index b668c8d4f..af38ddf72 100644 --- a/src/OT/Layout/GSUB/ReverseChainSingleSubstFormat1.hh +++ b/src/OT/Layout/GSUB/ReverseChainSingleSubstFormat1.hh @@ -68,8 +68,16 @@ struct ReverseChainSingleSubstFormat1 { return false; } #ifdef HB_DEPEND_API - // XXX not done yet - bool depend (hb_depend_context_t *c) const { return false; } + bool depend (hb_depend_context_t *c) const { + const auto &lookahead = StructAfter (backtrack); + const auto &substitute = StructAfter (lookahead); + + + hb_zip (this+coverage, substitute) + | hb_apply ([&] (const hb_codepoint_pair_t &_) { c->depend_data->add_gsub_lookup (_.first, c->lookup_index, _.second); }) + ; + + return true; + } #endif void closure (hb_closure_context_t *c) const diff --git a/src/hb-depend-data.hh b/src/hb-depend-data.hh index 33ecdb36a..0d9bb0e2e 100644 --- a/src/hb-depend-data.hh +++ b/src/hb-depend-data.hh @@ -119,12 +119,12 @@ struct hb_depend_data_t printf(" layout %c%c%c%c -> %u", HB_UNTAG(d.layout_tag), d.dependent); if (d.ligature_set != HB_CODEPOINT_INVALID) printf(" (ligature)"); - printf("\n"); } else { printf(" %c%c%c%c -> %u", HB_UNTAG(d.table_tag), d.dependent); if (d.table_tag == HB_TAG('c','m','a','p')) printf(" (UVS is %u)", d.layout_tag); } + printf("\n"); } } } diff --git a/src/hb-depend.cc b/src/hb-depend.cc index 64ee873c4..74786876b 100644 --- a/src/hb-depend.cc +++ b/src/hb-depend.cc @@ -62,6 +62,9 @@ hb_depend_t::hb_depend_t (hb_face_t *f) get_cmap_dependencies(); get_gsub_dependencies(); + get_math_dependencies(); + get_colr_dependencies(); + get_glyf_dependencies(); } void hb_depend_t::get_cmap_dependencies() {