diff --git a/src/OT/Color/COLR/COLR.hh b/src/OT/Color/COLR/COLR.hh index f5d209677..b082e0110 100644 --- a/src/OT/Color/COLR/COLR.hh +++ b/src/OT/Color/COLR/COLR.hh @@ -220,6 +220,8 @@ struct hb_colrv1_closure_context_t : {} }; +#ifdef HB_DEPEND_API + struct hb_colrv1_depend_context_t : hb_dispatch_context_t { @@ -254,6 +256,7 @@ struct hb_colrv1_depend_context_t : source_gid (0) {} }; +#endif /* HB_DEPEND_API */ struct LayerRecord { @@ -316,8 +319,10 @@ struct Variable return_trace (c->embed (this)); } +#ifdef HB_DEPEND_API void dependv1 (hb_colrv1_depend_context_t* c) const { value.dependv1 (c); } +#endif void closurev1 (hb_colrv1_closure_context_t* c) const { @@ -394,8 +399,10 @@ struct NoVariable return_trace (c->embed (this)); } +#ifdef HB_DEPEND_API void dependv1 (hb_colrv1_depend_context_t* c) const { value.dependv1 (c); } +#endif void closurev1 (hb_colrv1_closure_context_t* c) const { value.closurev1 (c); } @@ -440,7 +447,9 @@ struct NoVariable struct ColorStop { +#ifdef HB_DEPEND_API void dependv1 (hb_colrv1_depend_context_t * c) const {} +#endif void closurev1 (hb_colrv1_closure_context_t* c) const { @@ -504,11 +513,13 @@ struct Extend : HBUINT8 template class Var> struct ColorLine { +#ifdef HB_DEPEND_API void dependv1 (hb_colrv1_depend_context_t * c) const { for (const auto &stop : stops.iter ()) stop.dependv1 (c); } +#endif void closurev1 (hb_colrv1_closure_context_t* c) const { @@ -649,7 +660,9 @@ struct Affine2x3 return_trace (c->check_struct (this)); } +#ifdef HB_DEPEND_API void dependv1 (hb_colrv1_depend_context_t* c) const {} +#endif void closurev1 (hb_colrv1_closure_context_t* c) const { c->num_var_idxes = 6; } @@ -697,7 +710,9 @@ struct Affine2x3 struct PaintColrLayers { +#ifdef HB_DEPEND_API void dependv1 (hb_colrv1_depend_context_t* c) const; +#endif void closurev1 (hb_colrv1_closure_context_t* c) const; bool subset (hb_subset_context_t *c, @@ -729,7 +744,9 @@ struct PaintColrLayers struct PaintSolid { +#ifdef HB_DEPEND_API void dependv1 (hb_colrv1_depend_context_t* c) const {} +#endif void closurev1 (hb_colrv1_closure_context_t* c) const { c->add_palette_index (paletteIndex); @@ -782,10 +799,12 @@ struct PaintSolid template class Var> struct PaintLinearGradient { +#ifdef HB_DEPEND_API void dependv1 (hb_colrv1_depend_context_t* c) const { (this+colorLine).dependv1 (c); } +#endif void closurev1 (hb_colrv1_closure_context_t* c) const { @@ -857,10 +876,12 @@ struct PaintLinearGradient template class Var> struct PaintRadialGradient { +#ifdef HB_DEPEND_API void dependv1 (hb_colrv1_depend_context_t* c) const { (this+colorLine).dependv1 (c); } +#endif void closurev1 (hb_colrv1_closure_context_t* c) const { @@ -932,10 +953,12 @@ struct PaintRadialGradient template class Var> struct PaintSweepGradient { +#ifdef HB_DEPEND_API void dependv1 (hb_colrv1_depend_context_t* c) const { (this+colorLine).dependv1 (c); } +#endif void closurev1 (hb_colrv1_closure_context_t* c) const { @@ -1001,7 +1024,9 @@ struct PaintSweepGradient // Paint a non-COLR glyph, filled as indicated by paint. struct PaintGlyph { +#ifdef HB_DEPEND_API void dependv1 (hb_colrv1_depend_context_t* c) const; +#endif void closurev1 (hb_colrv1_closure_context_t* c) const; bool subset (hb_subset_context_t *c, @@ -1045,7 +1070,9 @@ struct PaintGlyph struct PaintColrGlyph { +#ifdef HB_DEPEND_API void dependv1 (hb_colrv1_depend_context_t* c) const; +#endif void closurev1 (hb_colrv1_closure_context_t* c) const; bool subset (hb_subset_context_t *c, @@ -1076,7 +1103,9 @@ struct PaintColrGlyph template class Var> struct PaintTransform { +#ifdef HB_DEPEND_API HB_INTERNAL void dependv1 (hb_colrv1_depend_context_t* c) const; +#endif HB_INTERNAL void closurev1 (hb_colrv1_closure_context_t* c) const; bool subset (hb_subset_context_t *c, @@ -1116,7 +1145,9 @@ struct PaintTransform struct PaintTranslate { +#ifdef HB_DEPEND_API HB_INTERNAL void dependv1 (hb_colrv1_depend_context_t* c) const; +#endif HB_INTERNAL void closurev1 (hb_colrv1_closure_context_t* c) const; bool subset (hb_subset_context_t *c, @@ -1166,7 +1197,9 @@ struct PaintTranslate struct PaintScale { +#ifdef HB_DEPEND_API HB_INTERNAL void dependv1 (hb_colrv1_depend_context_t* c) const; +#endif HB_INTERNAL void closurev1 (hb_colrv1_closure_context_t* c) const; bool subset (hb_subset_context_t *c, @@ -1216,7 +1249,9 @@ struct PaintScale struct PaintScaleAroundCenter { +#ifdef HB_DEPEND_API HB_INTERNAL void dependv1 (hb_colrv1_depend_context_t* c) const; +#endif HB_INTERNAL void closurev1 (hb_colrv1_closure_context_t* c) const; bool subset (hb_subset_context_t *c, @@ -1272,7 +1307,9 @@ struct PaintScaleAroundCenter struct PaintScaleUniform { +#ifdef HB_DEPEND_API HB_INTERNAL void dependv1 (hb_colrv1_depend_context_t* c) const; +#endif HB_INTERNAL void closurev1 (hb_colrv1_closure_context_t* c) const; bool subset (hb_subset_context_t *c, @@ -1317,7 +1354,9 @@ struct PaintScaleUniform struct PaintScaleUniformAroundCenter { +#ifdef HB_DEPEND_API HB_INTERNAL void dependv1 (hb_colrv1_depend_context_t* c) const; +#endif HB_INTERNAL void closurev1 (hb_colrv1_closure_context_t* c) const; bool subset (hb_subset_context_t *c, @@ -1370,7 +1409,9 @@ struct PaintScaleUniformAroundCenter struct PaintRotate { +#ifdef HB_DEPEND_API HB_INTERNAL void dependv1 (hb_colrv1_depend_context_t* c) const; +#endif HB_INTERNAL void closurev1 (hb_colrv1_closure_context_t* c) const; bool subset (hb_subset_context_t *c, @@ -1415,7 +1456,9 @@ struct PaintRotate struct PaintRotateAroundCenter { +#ifdef HB_DEPEND_API HB_INTERNAL void dependv1 (hb_colrv1_depend_context_t* c) const; +#endif HB_INTERNAL void closurev1 (hb_colrv1_closure_context_t* c) const; bool subset (hb_subset_context_t *c, @@ -1468,7 +1511,9 @@ struct PaintRotateAroundCenter struct PaintSkew { +#ifdef HB_DEPEND_API HB_INTERNAL void dependv1 (hb_colrv1_depend_context_t* c) const; +#endif HB_INTERNAL void closurev1 (hb_colrv1_closure_context_t* c) const; bool subset (hb_subset_context_t *c, @@ -1518,7 +1563,9 @@ struct PaintSkew struct PaintSkewAroundCenter { +#ifdef HB_DEPEND_API HB_INTERNAL void dependv1 (hb_colrv1_depend_context_t* c) const; +#endif HB_INTERNAL void closurev1 (hb_colrv1_closure_context_t* c) const; bool subset (hb_subset_context_t *c, @@ -1574,7 +1621,9 @@ struct PaintSkewAroundCenter struct PaintComposite { +#ifdef HB_DEPEND_API void dependv1 (hb_colrv1_depend_context_t* c) const; +#endif void closurev1 (hb_colrv1_closure_context_t* c) const; bool subset (hb_subset_context_t *c, @@ -1685,7 +1734,9 @@ struct ClipBoxFormat2 : Variable } } +#ifdef HB_DEPEND_API void dependv1 (hb_colrv1_depend_context_t* c) const; +#endif void closurev1 (hb_colrv1_closure_context_t* c) const { c->variation_indices->add_range (varIdxBase, varIdxBase + 3); } }; @@ -1703,6 +1754,7 @@ struct ClipBox } } +#ifdef HB_DEPEND_API void dependv1 (hb_colrv1_depend_context_t* c) const { switch (u.format) { @@ -1710,6 +1762,7 @@ struct ClipBox default:return; } } +#endif void closurev1 (hb_colrv1_closure_context_t* c) const { @@ -1766,10 +1819,12 @@ struct ClipRecord int cmp (hb_codepoint_t g) const { return g < startGlyphID ? -1 : g <= endGlyphID ? 0 : +1; } +#ifdef HB_DEPEND_API void dependv1 (hb_colrv1_depend_context_t* c, const void *base) const { (base+clipBox).dependv1 (c); } +#endif void closurev1 (hb_colrv1_closure_context_t* c, const void *base) const { @@ -2271,8 +2326,10 @@ struct COLR bool is_valid () { return colr.get_blob ()->length; } +#ifdef HB_DEPEND_API void depend (hb_depend_data_t *depend_data) const { colr->depend (depend_data); } +#endif void closure_glyphs (hb_codepoint_t glyph, hb_set_t *related_ids /* OUT */) const diff --git a/src/OT/Color/COLR/colrv1-depend.hh b/src/OT/Color/COLR/colrv1-depend.hh new file mode 100644 index 000000000..677e48cb1 --- /dev/null +++ b/src/OT/Color/COLR/colrv1-depend.hh @@ -0,0 +1,130 @@ +/* + * Copyright © 2025 Skef Iterum + * + * 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. + * + */ + +#ifndef OT_COLOR_COLR_COLRV1_DEPEND_HH +#define OT_COLOR_COLR_COLRV1_DEPEND_HH + +#include "../../../hb-open-type.hh" +#include "COLR.hh" + +/* + * COLR -- Color + * https://docs.microsoft.com/en-us/typography/opentype/spec/colr + */ +namespace OT { + +#ifdef HB_DEPEND_API + +HB_INTERNAL void PaintColrLayers::dependv1 (hb_colrv1_depend_context_t* c) const +{ + const LayerList &paint_offset_lists = c->get_colr_table ()->get_layerList (); + for (unsigned i = firstLayerIndex; i < firstLayerIndex + numLayers; i++) + { + const Paint &paint = std::addressof (paint_offset_lists) + paint_offset_lists[i]; + paint.dispatch (c); + } +} + +HB_INTERNAL void PaintGlyph::dependv1 (hb_colrv1_depend_context_t* c) const +{ + c->depend_data->add_depend(c->source_gid, HB_OT_TAG_COLR, gid); + (this+paint).dispatch (c); +} + +HB_INTERNAL void PaintColrGlyph::dependv1 (hb_colrv1_depend_context_t* c) const +{ + const COLR *colr_table = c->get_colr_table (); + const BaseGlyphPaintRecord* baseglyph_paintrecord = colr_table->get_base_glyph_paintrecord (gid); + if (!baseglyph_paintrecord) return; + c->depend_data->add_depend(c->source_gid, HB_OT_TAG_COLR, gid); + + const BaseGlyphList &baseglyph_list = colr_table->get_baseglyphList (); + (&baseglyph_list+baseglyph_paintrecord->paint).dispatch (c); +} + +template class Var> +HB_INTERNAL void PaintTransform::dependv1 (hb_colrv1_depend_context_t* c) const +{ + (this+src).dispatch (c); + (this+transform).dependv1 (c); +} + +HB_INTERNAL void PaintTranslate::dependv1 (hb_colrv1_depend_context_t* c) const +{ + (this+src).dispatch (c); +} + +HB_INTERNAL void PaintScale::dependv1 (hb_colrv1_depend_context_t* c) const +{ + (this+src).dispatch (c); +} + +HB_INTERNAL void PaintScaleAroundCenter::dependv1 (hb_colrv1_depend_context_t* c) const +{ + (this+src).dispatch (c); +} + +HB_INTERNAL void PaintScaleUniform::dependv1 (hb_colrv1_depend_context_t* c) const +{ + (this+src).dispatch (c); +} + +HB_INTERNAL void PaintScaleUniformAroundCenter::dependv1 (hb_colrv1_depend_context_t* c) const +{ + (this+src).dispatch (c); +} + +HB_INTERNAL void PaintRotate::dependv1 (hb_colrv1_depend_context_t* c) const +{ + (this+src).dispatch (c); +} + +HB_INTERNAL void PaintRotateAroundCenter::dependv1 (hb_colrv1_depend_context_t* c) const +{ + (this+src).dispatch (c); +} + +HB_INTERNAL void PaintSkew::dependv1 (hb_colrv1_depend_context_t* c) const +{ + (this+src).dispatch (c); +} + +HB_INTERNAL void PaintSkewAroundCenter::dependv1 (hb_colrv1_depend_context_t* c) const +{ + (this+src).dispatch (c); +} + +HB_INTERNAL void PaintComposite::dependv1 (hb_colrv1_depend_context_t* c) const +{ + (this+src).dispatch (c); + (this+backdrop).dispatch (c); +} + +#endif + +} /* namespace OT */ + + +#endif /* OT_COLOR_COLR_COLRV1_DEPEND_HH */ diff --git a/src/OT/Layout/GSUB/AlternateSet.hh b/src/OT/Layout/GSUB/AlternateSet.hh index 1fc2265d9..09a8960e3 100644 --- a/src/OT/Layout/GSUB/AlternateSet.hh +++ b/src/OT/Layout/GSUB/AlternateSet.hh @@ -29,12 +29,14 @@ struct AlternateSet void closure (hb_closure_context_t *c) const { c->output->add_array (alternates.arrayZ, alternates.len); } +#ifdef HB_DEPEND_API void depend (hb_depend_context_t *c, hb_codepoint_t source) const { + hb_iter (alternates) | hb_apply ([&] (const hb_codepoint_t &target) { c->depend_data->add_gsub_lookup (source, c->lookup_index, target); }) ; } +#endif void collect_glyphs (hb_collect_glyphs_context_t *c) const { c->output->add_array (alternates.arrayZ, alternates.len); } diff --git a/src/OT/Layout/GSUB/AlternateSubstFormat1.hh b/src/OT/Layout/GSUB/AlternateSubstFormat1.hh index fb1788f7d..5f9a08d3e 100644 --- a/src/OT/Layout/GSUB/AlternateSubstFormat1.hh +++ b/src/OT/Layout/GSUB/AlternateSubstFormat1.hh @@ -34,6 +34,7 @@ struct AlternateSubstFormat1_2 bool may_have_non_1to1 () const { return false; } +#ifdef HB_DEPEND_API bool depend (hb_depend_context_t *c) const { + hb_zip (this+coverage, alternateSet) @@ -45,6 +46,7 @@ struct AlternateSubstFormat1_2 ; return true; } +#endif void closure (hb_closure_context_t *c) const { diff --git a/src/OT/Layout/GSUB/Ligature.hh b/src/OT/Layout/GSUB/Ligature.hh index 2b8207929..f9405fa5b 100644 --- a/src/OT/Layout/GSUB/Ligature.hh +++ b/src/OT/Layout/GSUB/Ligature.hh @@ -38,6 +38,7 @@ struct Ligature c->output->add (ligGlyph); } +#ifdef HB_DEPEND_API void depend (hb_depend_context_t *c, hb_codepoint_t first) const { hb_codepoint_t ligset = c->depend_data->new_set(first); @@ -50,6 +51,7 @@ struct Ligature }) ; } +#endif void collect_glyphs (hb_collect_glyphs_context_t *c) const { diff --git a/src/OT/Layout/GSUB/LigatureSet.hh b/src/OT/Layout/GSUB/LigatureSet.hh index cefae5d40..b81aa21d8 100644 --- a/src/OT/Layout/GSUB/LigatureSet.hh +++ b/src/OT/Layout/GSUB/LigatureSet.hh @@ -54,6 +54,7 @@ struct LigatureSet ; } +#ifdef HB_DEPEND_API void depend (hb_depend_context_t *c, hb_codepoint_t first) const { + hb_iter (ligature) @@ -61,6 +62,7 @@ struct LigatureSet | hb_apply ([&] (const Ligature &_) { _.depend (c, first); }) ; } +#endif void collect_glyphs (hb_collect_glyphs_context_t *c) const { diff --git a/src/OT/Layout/GSUB/LigatureSubstFormat1.hh b/src/OT/Layout/GSUB/LigatureSubstFormat1.hh index eae0c7dcb..e43b420a8 100644 --- a/src/OT/Layout/GSUB/LigatureSubstFormat1.hh +++ b/src/OT/Layout/GSUB/LigatureSubstFormat1.hh @@ -43,6 +43,7 @@ struct LigatureSubstFormat1_2 bool may_have_non_1to1 () const { return true; } +#ifdef HB_DEPEND_API bool depend (hb_depend_context_t *c) const { + hb_zip (this+coverage, ligatureSet) @@ -54,6 +55,7 @@ struct LigatureSubstFormat1_2 ; return true; } +#endif void closure (hb_closure_context_t *c) const { diff --git a/src/OT/Layout/GSUB/MultipleSubstFormat1.hh b/src/OT/Layout/GSUB/MultipleSubstFormat1.hh index 82ac77ef9..5d535b6d5 100644 --- a/src/OT/Layout/GSUB/MultipleSubstFormat1.hh +++ b/src/OT/Layout/GSUB/MultipleSubstFormat1.hh @@ -44,6 +44,7 @@ struct MultipleSubstFormat1_2 ; } +#ifdef HB_DEPEND_API bool depend (hb_depend_context_t *c) const { + hb_zip (this+coverage, sequence) @@ -55,6 +56,7 @@ struct MultipleSubstFormat1_2 ; return true; } +#endif void closure_lookups (hb_closure_lookups_context_t *c) const {} diff --git a/src/OT/Layout/GSUB/ReverseChainSingleSubstFormat1.hh b/src/OT/Layout/GSUB/ReverseChainSingleSubstFormat1.hh index a69f2727d..b668c8d4f 100644 --- a/src/OT/Layout/GSUB/ReverseChainSingleSubstFormat1.hh +++ b/src/OT/Layout/GSUB/ReverseChainSingleSubstFormat1.hh @@ -67,7 +67,10 @@ struct ReverseChainSingleSubstFormat1 bool may_have_non_1to1 () const { return false; } +#ifdef HB_DEPEND_API + // XXX not done yet bool depend (hb_depend_context_t *c) const { return false; } +#endif void closure (hb_closure_context_t *c) const { diff --git a/src/OT/Layout/GSUB/Sequence.hh b/src/OT/Layout/GSUB/Sequence.hh index 9c5dc864d..5f32b1d74 100644 --- a/src/OT/Layout/GSUB/Sequence.hh +++ b/src/OT/Layout/GSUB/Sequence.hh @@ -28,12 +28,14 @@ struct Sequence void closure (hb_closure_context_t *c) const { c->output->add_array (substitute.arrayZ, substitute.len); } +#ifdef HB_DEPEND_API void depend (hb_depend_context_t *c, hb_codepoint_t source) const { + hb_iter (substitute) | hb_apply ([&] (const hb_codepoint_t &target) { c->depend_data->add_gsub_lookup (source, c->lookup_index, target); }) ; } +#endif void collect_glyphs (hb_collect_glyphs_context_t *c) const { c->output->add_array (substitute.arrayZ, substitute.len); } diff --git a/src/OT/Layout/GSUB/SingleSubstFormat1.hh b/src/OT/Layout/GSUB/SingleSubstFormat1.hh index c144ba1bd..110548b73 100644 --- a/src/OT/Layout/GSUB/SingleSubstFormat1.hh +++ b/src/OT/Layout/GSUB/SingleSubstFormat1.hh @@ -45,6 +45,7 @@ struct SingleSubstFormat1_3 bool may_have_non_1to1 () const { return false; } +#ifdef HB_DEPEND_API bool depend (hb_depend_context_t *c) const { hb_codepoint_t d = deltaGlyphID; @@ -56,6 +57,7 @@ struct SingleSubstFormat1_3 ; return true; } +#endif void closure (hb_closure_context_t *c) const { diff --git a/src/OT/Layout/GSUB/SingleSubstFormat2.hh b/src/OT/Layout/GSUB/SingleSubstFormat2.hh index 3293fcff1..df01b1fc6 100644 --- a/src/OT/Layout/GSUB/SingleSubstFormat2.hh +++ b/src/OT/Layout/GSUB/SingleSubstFormat2.hh @@ -34,6 +34,7 @@ struct SingleSubstFormat2_4 bool may_have_non_1to1 () const { return false; } +#ifdef HB_DEPEND_API bool depend (hb_depend_context_t *c) const { auto &cov = this+coverage; @@ -43,6 +44,7 @@ struct SingleSubstFormat2_4 ; return true; } +#endif void closure (hb_closure_context_t *c) const { diff --git a/src/OT/Layout/GSUB/SubstLookup.hh b/src/OT/Layout/GSUB/SubstLookup.hh index b35a333b2..433e74f18 100644 --- a/src/OT/Layout/GSUB/SubstLookup.hh +++ b/src/OT/Layout/GSUB/SubstLookup.hh @@ -61,10 +61,12 @@ struct SubstLookup : Lookup return ret; } +#ifdef HB_DEPEND_API hb_depend_context_t::return_t depend (hb_depend_context_t *c) const { return dispatch (c); } +#endif hb_closure_lookups_context_t::return_t closure_lookups (hb_closure_lookups_context_t *c, unsigned this_index) const { @@ -210,7 +212,9 @@ struct SubstLookup : Lookup return ret; } +#ifdef HB_DEPEND_API static typename hb_depend_context_t::return_t depend_recurse_func (hb_depend_context_t *c, unsigned lookup_index); +#endif template typename context_t::return_t dispatch (context_t *c, Ts&&... ds) const diff --git a/src/hb-depend-data.hh b/src/hb-depend-data.hh index d401a2a8b..33ecdb36a 100644 --- a/src/hb-depend-data.hh +++ b/src/hb-depend-data.hh @@ -27,11 +27,12 @@ #ifndef HB_DEPEND_DATA_HH #define HB_DEPEND_DATA_HH - #include "hb.hh" #include "hb-multimap.hh" +#ifdef HB_DEPEND_API + struct hb_depend_data_record_t { hb_depend_data_record_t() = delete; hb_depend_data_record_t(hb_tag_t table_tag, @@ -219,4 +220,6 @@ struct hb_depend_data_t hb_vector_t lookup_features; }; +#endif /* HB_DEPEND_API */ + #endif /* HB_DEPEND_DATA_HH */ diff --git a/src/hb-depend.cc b/src/hb-depend.cc index 1eb57a928..64ee873c4 100644 --- a/src/hb-depend.cc +++ b/src/hb-depend.cc @@ -36,6 +36,8 @@ #include "OT/Color/COLR/COLR.hh" #include "OT/Color/COLR/colrv1-depend.hh" +#ifdef HB_DEPEND_API + /** * SECTION:hb-depend * @title: hb-depend @@ -261,3 +263,5 @@ hb_depend_destroy (hb_depend_t *depend) hb_free (depend); } + +#endif /* HB_DEPEND_API */ diff --git a/src/hb-depend.h b/src/hb-depend.h index c89eaeb14..59d834f93 100644 --- a/src/hb-depend.h +++ b/src/hb-depend.h @@ -24,14 +24,18 @@ * Adobe Author(s): Skef Iterum */ +#if !defined(HB_H_IN) && !defined(HB_NO_SINGLE_HEADER_ERROR) +#error "Include instead." +#endif + #ifndef HB_DEPEND_H #define HB_DEPEND_H -#include "hb.h" -#include "hb-ot.h" HB_BEGIN_DECLS +#ifdef HB_DEPEND_API + /** * hb_depend_t: * @@ -63,6 +67,8 @@ hb_depend_print (hb_depend_t *depend); HB_EXTERN void hb_depend_destroy(hb_depend_t *depend); +#endif + HB_END_DECLS #endif /* HB_DEPEND_H */ diff --git a/src/hb-depend.hh b/src/hb-depend.hh index 1efab2099..1a2b35a59 100644 --- a/src/hb-depend.hh +++ b/src/hb-depend.hh @@ -32,6 +32,8 @@ #include "hb-depend.h" #include "hb-depend-data.hh" +#ifdef HB_DEPEND_API + struct hb_depend_t { HB_INTERNAL hb_depend_t (hb_face_t *face); @@ -74,4 +76,6 @@ struct hb_depend_t hb_depend_data_t data; }; +#endif /* HB_DEPEND_API */ + #endif /* HB_DEPEND_HH */ diff --git a/src/hb-ot-cmap-table.hh b/src/hb-ot-cmap-table.hh index 7672def11..4a0866d2e 100644 --- a/src/hb-ot-cmap-table.hh +++ b/src/hb-ot-cmap-table.hh @@ -1199,6 +1199,7 @@ struct NonDefaultUVS : SortedArray32Of ; } +#ifdef HB_DEPEND_API void depend (hb_depend_data_t *depend_data, hb_codepoint_t sel) const { for (const auto& a : as_array ()) @@ -1210,6 +1211,7 @@ struct NonDefaultUVS : SortedArray32Of static_cast(sel), a.glyphID); } } +#endif NonDefaultUVS* copy (hb_serialize_context_t *c, const hb_set_t *unicodes, @@ -1277,12 +1279,14 @@ struct VariationSelectorRecord nonDefaultUVS = offset; } +#ifdef HB_DEPEND_API void depend (hb_depend_data_t *depend_data, const void *base) const { if (!nonDefaultUVS) return; (base+nonDefaultUVS).depend(depend_data, varSelector); } +#endif void collect_unicodes (hb_set_t *out, const void *base) const { @@ -1470,11 +1474,13 @@ struct CmapSubtableFormat14 ; } +#ifdef HB_DEPEND_API void depend (hb_depend_data_t *depend_data) const { for (const VariationSelectorRecord& _ : record) _.depend (depend_data, this); } +#endif void collect_unicodes (hb_set_t *out) const { @@ -1938,6 +1944,7 @@ struct cmap ; } +#ifdef HB_DEPEND_API void depend (hb_depend_data_t *depend_data) const { + hb_iter (encodingRecord) @@ -1947,6 +1954,7 @@ struct cmap | hb_apply ([=] (const CmapSubtable& _) { _.u.format14.depend (depend_data); }) ; } +#endif bool subset (hb_subset_context_t *c) const { diff --git a/src/hb-ot-layout-gsubgpos.hh b/src/hb-ot-layout-gsubgpos.hh index ce78382ce..f8a10277e 100644 --- a/src/hb-ot-layout-gsubgpos.hh +++ b/src/hb-ot-layout-gsubgpos.hh @@ -376,6 +376,7 @@ struct hb_collect_glyphs_context_t : void set_recurse_func (recurse_func_t func) { recurse_func = func; } }; +#ifdef HB_DEPEND_API struct hb_depend_context_t : hb_dispatch_context_t { @@ -404,6 +405,7 @@ struct hb_depend_context_t : recurse_func (nullptr) {} void set_recurse_func (recurse_func_t func) { recurse_func = func; } }; +#endif template struct hb_collect_coverage_context_t : @@ -1788,6 +1790,7 @@ static void context_closure_recurse_lookups (hb_closure_context_t *c, } } +#ifdef HB_DEPEND_API template static void context_depend_recurse_lookups (hb_depend_context_t *c, unsigned inputCount HB_UNUSED, const HBUINT input[] HB_UNUSED, @@ -1807,6 +1810,7 @@ static void context_depend_recurse_lookups (hb_depend_context_t *c, for (unsigned int i = 0; i < lookupCount; i++) c->recurse (lookupRecord[i].lookupListIndex); } +#endif template static inline void recurse_lookups (context_t *c, @@ -2118,6 +2122,7 @@ struct Rule lookup_context); } +#ifdef HB_DEPEND_API void depend (hb_depend_context_t *c, unsigned value) const { const auto &lookupRecord = StructAfter> @@ -2127,6 +2132,7 @@ struct Rule lookupCount, lookupRecord.arrayZ, value); } +#endif void closure (hb_closure_context_t *c, unsigned value, ContextClosureLookupContext &lookup_context) const { @@ -2261,6 +2267,7 @@ struct RuleSet ; } +#ifdef HB_DEPEND_API void depend (hb_depend_context_t *c, unsigned value) const { + hb_iter (rule) @@ -2268,6 +2275,7 @@ struct RuleSet | hb_apply ([&] (const Rule &_) { _.depend (c, value); }) ; } +#endif void closure (hb_closure_context_t *c, unsigned value, ContextClosureLookupContext &lookup_context) const @@ -2509,6 +2517,7 @@ struct ContextFormat1_4 bool may_have_non_1to1 () const { return true; } +#ifdef HB_DEPEND_API bool depend (hb_depend_context_t *c) const { + hb_zip (this+coverage, hb_range ((unsigned) ruleSet.len)) @@ -2517,6 +2526,7 @@ struct ContextFormat1_4 ; return true; } +#endif void closure (hb_closure_context_t *c) const { @@ -2686,6 +2696,7 @@ struct ContextFormat2_5 bool may_have_non_1to1 () const { return true; } +#ifdef HB_DEPEND_API bool depend (hb_depend_context_t *c) const { + hb_enumerate (ruleSet) @@ -2697,6 +2708,7 @@ struct ContextFormat2_5 ; return true; } +#endif void closure (hb_closure_context_t *c) const { @@ -2938,6 +2950,7 @@ struct ContextFormat3 bool may_have_non_1to1 () const { return true; } +#ifdef HB_DEPEND_API bool depend (hb_depend_context_t *c) const { const LookupRecord *lookupRecord = &StructAfter (coverageZ.as_array (glyphCount)); @@ -2947,6 +2960,7 @@ struct ContextFormat3 0); return true; } +#endif void closure (hb_closure_context_t *c) const { @@ -3303,6 +3317,7 @@ struct ChainRule lookup_context); } +#ifdef HB_DEPEND_API void depend (hb_depend_context_t *c, unsigned value) const { const auto &input = StructAfter (backtrack); @@ -3314,6 +3329,7 @@ struct ChainRule lookup.len, lookup.arrayZ, value); } +#endif void closure (hb_closure_context_t *c, unsigned value, ChainContextClosureLookupContext &lookup_context) const @@ -3509,6 +3525,7 @@ struct ChainRuleSet | hb_any ; } +#ifdef HB_DEPEND_API void depend (hb_depend_context_t *c, unsigned value) const { + hb_iter (rule) @@ -3516,6 +3533,7 @@ struct ChainRuleSet | hb_apply ([&] (const ChainRule &_) { _.depend (c, value); }) ; } +#endif void closure (hb_closure_context_t *c, unsigned value, ChainContextClosureLookupContext &lookup_context) const { if (unlikely (c->lookup_limit_exceeded ())) return; @@ -3778,6 +3796,7 @@ struct ChainContextFormat1_4 bool may_have_non_1to1 () const { return true; } +#ifdef HB_DEPEND_API bool depend (hb_depend_context_t *c) const { + hb_zip (this+coverage, hb_range ((unsigned) ruleSet.len)) @@ -3786,6 +3805,7 @@ struct ChainContextFormat1_4 ; return true; } +#endif void closure (hb_closure_context_t *c) const { @@ -3957,6 +3977,7 @@ struct ChainContextFormat2_5 bool may_have_non_1to1 () const { return true; } +#ifdef HB_DEPEND_API bool depend (hb_depend_context_t *c) const { + hb_enumerate (ruleSet) @@ -3969,6 +3990,7 @@ struct ChainContextFormat2_5 return true; } +#endif void closure (hb_closure_context_t *c) const { @@ -4267,6 +4289,7 @@ struct ChainContextFormat3 bool may_have_non_1to1 () const { return true; } +#ifdef HB_DEPEND_API bool depend (hb_depend_context_t *c) const { const auto &input = StructAfter (backtrack); @@ -4280,6 +4303,7 @@ struct ChainContextFormat3 return false; } +#endif void closure (hb_closure_context_t *c) const { diff --git a/src/hb-ot-math-table.hh b/src/hb-ot-math-table.hh index caf0225b8..875cfd766 100644 --- a/src/hb-ot-math-table.hh +++ b/src/hb-ot-math-table.hh @@ -663,8 +663,10 @@ struct MathGlyphVariantRecord return_trace (c->check_struct (this)); } +#ifdef HB_DEPEND_API void depend (hb_depend_data_t *depend_data, unsigned source) const { depend_data->add_depend(source, HB_OT_TAG_MATH, variantGlyph); } +#endif void closure_glyphs (hb_set_t *variant_glyphs) const { variant_glyphs->add (variantGlyph); } @@ -727,8 +729,10 @@ struct MathGlyphPartRecord (partFlags & PartFlags::Defined); } +#ifdef HB_DEPEND_API void depend (hb_depend_data_t *depend_data, unsigned source) const { depend_data->add_depend(source, HB_OT_TAG_MATH, glyph); } +#endif void closure_glyphs (hb_set_t *variant_glyphs) const { variant_glyphs->add (glyph); } @@ -797,11 +801,13 @@ struct MathGlyphAssembly return partRecords.len; } +#ifdef HB_DEPEND_API void depend (hb_depend_data_t *depend_data, unsigned source) const { for (const auto& _ : partRecords.iter ()) _.depend (depend_data, source); } +#endif void closure_glyphs (hb_set_t *variant_glyphs) const { @@ -868,6 +874,7 @@ struct MathGlyphConstruction return mathGlyphVariantRecord.len; } +#ifdef HB_DEPEND_API void depend (hb_depend_data_t *depend_data, unsigned source) const { (this+glyphAssembly).depend (depend_data, source); @@ -875,6 +882,7 @@ struct MathGlyphConstruction for (const auto& _ : mathGlyphVariantRecord.iter ()) _.depend (depend_data, source); } +#endif void closure_glyphs (hb_set_t *variant_glyphs) const { @@ -898,6 +906,7 @@ struct MathGlyphConstruction struct MathVariants { +#ifdef HB_DEPEND_API void depend (hb_depend_data_t *depend_data) const { const hb_array_t> glyph_construction_offsets = glyphConstruction.as_array (vertGlyphCount + horizGlyphCount); @@ -925,6 +934,7 @@ struct MathVariants ; } } +#endif void closure_glyphs (const hb_set_t *glyph_set, hb_set_t *variant_glyphs) const @@ -1122,11 +1132,13 @@ struct MATH bool has_data () const { return version.to_int (); } +#ifdef HB_DEPEND_API void depend (hb_depend_data_t *depend_data) const { if (mathVariants) (this+mathVariants).depend (depend_data); } +#endif void closure_glyphs (hb_set_t *glyph_set) const { diff --git a/src/hb.h b/src/hb.h index 5a6ae6607..622f81992 100644 --- a/src/hb.h +++ b/src/hb.h @@ -31,6 +31,7 @@ #include "hb-blob.h" #include "hb-buffer.h" #include "hb-common.h" +#include "hb-depend.h" #include "hb-deprecated.h" #include "hb-draw.h" #include "hb-face.h" diff --git a/src/meson.build b/src/meson.build index dda78e845..a4c6da134 100644 --- a/src/meson.build +++ b/src/meson.build @@ -430,7 +430,7 @@ hb_subset_sources = files( hb_subset_headers = files( 'hb-subset.h', - 'hb-subset-serialize.h' + 'hb-subset-serialize.h', 'hb-depend.h', )