From a878c58a8fc1500986d713b2bcedfeb90a0087b0 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Wed, 1 Aug 2012 21:18:54 -0400 Subject: [PATCH] [GSUB/GPOS] Add add_coverage() --- src/hb-ot-layout-gpos-table.hh | 18 ++++++++++++++++++ src/hb-ot-layout-gsub-table.hh | 18 ++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/src/hb-ot-layout-gpos-table.hh b/src/hb-ot-layout-gpos-table.hh index cffbd25be..3b0b8819e 100644 --- a/src/hb-ot-layout-gpos-table.hh +++ b/src/hb-ot-layout-gpos-table.hh @@ -1511,6 +1511,20 @@ struct PosLookup : Lookup return c; } + template + inline void add_coverage (set_t *glyphs) const + { + const Coverage *last = NULL; + unsigned int count = get_subtable_count (); + for (unsigned int i = 0; i < count; i++) { + const Coverage *c = &get_subtable (i).get_coverage (get_type ()); + if (c != last) { + c->add_coverage (glyphs); + last = c; + } + } + } + inline bool apply_once (hb_apply_context_t *c) const { unsigned int lookup_type = get_type (); @@ -1583,6 +1597,10 @@ struct GPOS : GSUBGPOS inline const PosLookup& get_lookup (unsigned int i) const { return CastR (GSUBGPOS::get_lookup (i)); } + template + inline void add_coverage (set_t *glyphs, unsigned int lookup_index) const + { get_lookup (lookup_index).add_coverage (glyphs); } + inline bool position_lookup (hb_apply_context_t *c, unsigned int lookup_index) const { return get_lookup (lookup_index).apply_string (c); } diff --git a/src/hb-ot-layout-gsub-table.hh b/src/hb-ot-layout-gsub-table.hh index 605ddb56b..ca91a2597 100644 --- a/src/hb-ot-layout-gsub-table.hh +++ b/src/hb-ot-layout-gsub-table.hh @@ -1165,6 +1165,20 @@ struct SubstLookup : Lookup return c; } + template + inline void add_coverage (set_t *glyphs) const + { + const Coverage *last = NULL; + unsigned int count = get_subtable_count (); + for (unsigned int i = 0; i < count; i++) { + const Coverage *c = &get_subtable (i).get_coverage (get_type ()); + if (c != last) { + c->add_coverage (glyphs); + last = c; + } + } + } + inline bool would_apply (hb_would_apply_context_t *c) const { unsigned int lookup_type = get_type (); @@ -1284,6 +1298,10 @@ struct GSUB : GSUBGPOS inline const SubstLookup& get_lookup (unsigned int i) const { return CastR (GSUBGPOS::get_lookup (i)); } + template + inline void add_coverage (set_t *glyphs, unsigned int lookup_index) const + { get_lookup (lookup_index).add_coverage (glyphs); } + inline bool would_substitute_lookup (hb_would_apply_context_t *c, unsigned int lookup_index) const { return get_lookup (lookup_index).would_apply (c); }