From ea11029a6e72be7b5f0f3b815dd7b78a105195fa Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Fri, 8 Jul 2022 11:58:43 -0600 Subject: [PATCH] [GPOS] Split LigatureArray.hh --- src/Makefile.sources | 1 + src/OT/Layout/GPOS/LigatureArray.hh | 56 +++++++++++++++++++++++++ src/OT/Layout/GPOS/MarkLigPosFormat1.hh | 43 +------------------ src/meson.build | 1 + 4 files changed, 60 insertions(+), 41 deletions(-) create mode 100644 src/OT/Layout/GPOS/LigatureArray.hh diff --git a/src/Makefile.sources b/src/Makefile.sources index 1e339ef7c..81ddc246c 100644 --- a/src/Makefile.sources +++ b/src/Makefile.sources @@ -109,6 +109,7 @@ HB_BASE_sources = \ OT/Layout/GPOS/CursivePos.hh \ OT/Layout/GPOS/ExtensionPos.hh \ OT/Layout/GPOS/GPOS.hh \ + OT/Layout/GPOS/LigatureArray.hh \ OT/Layout/GPOS/MarkArray.hh \ OT/Layout/GPOS/MarkBasePosFormat1.hh \ OT/Layout/GPOS/MarkBasePos.hh \ diff --git a/src/OT/Layout/GPOS/LigatureArray.hh b/src/OT/Layout/GPOS/LigatureArray.hh new file mode 100644 index 000000000..a2d807cc3 --- /dev/null +++ b/src/OT/Layout/GPOS/LigatureArray.hh @@ -0,0 +1,56 @@ +#ifndef OT_LAYOUT_GPOS_LIGATUREARRAY_HH +#define OT_LAYOUT_GPOS_LIGATUREARRAY_HH + +namespace OT { +namespace Layout { +namespace GPOS_impl { + + +typedef AnchorMatrix LigatureAttach; /* component-major-- + * in order of writing direction--, + * mark-minor-- + * ordered by class--zero-based. */ + +/* Array of LigatureAttach tables ordered by LigatureCoverage Index */ +struct LigatureArray : List16OfOffset16To +{ + template + bool subset (hb_subset_context_t *c, + Iterator coverage, + unsigned class_count, + const hb_map_t *klass_mapping) const + { + TRACE_SUBSET (this); + const hb_set_t &glyphset = *c->plan->glyphset_gsub (); + + auto *out = c->serializer->start_embed (this); + if (unlikely (!c->serializer->extend_min (out))) return_trace (false); + + for (const auto _ : + hb_zip (coverage, *this) + | hb_filter (glyphset, hb_first)) + { + auto *matrix = out->serialize_append (c->serializer); + if (unlikely (!matrix)) return_trace (false); + + const LigatureAttach& src = (this + _.second); + auto indexes = + + hb_range (src.rows * class_count) + | hb_filter ([=] (unsigned index) { return klass_mapping->has (index % class_count); }) + ; + matrix->serialize_subset (c, + _.second, + this, + src.rows, + indexes); + } + return_trace (this->len); + } +}; + + +} +} +} + +#endif /* OT_LAYOUT_GPOS_LIGATUREARRAY_HH */ diff --git a/src/OT/Layout/GPOS/MarkLigPosFormat1.hh b/src/OT/Layout/GPOS/MarkLigPosFormat1.hh index 4382aa6c6..112c92803 100644 --- a/src/OT/Layout/GPOS/MarkLigPosFormat1.hh +++ b/src/OT/Layout/GPOS/MarkLigPosFormat1.hh @@ -1,51 +1,12 @@ #ifndef OT_LAYOUT_GPOS_MARKLIGPOSFORMAT1_HH #define OT_LAYOUT_GPOS_MARKLIGPOSFORMAT1_HH +#include "LigatureArray.hh" + namespace OT { namespace Layout { namespace GPOS_impl { -typedef AnchorMatrix LigatureAttach; /* component-major-- - * in order of writing direction--, - * mark-minor-- - * ordered by class--zero-based. */ - -/* Array of LigatureAttach tables ordered by LigatureCoverage Index */ -struct LigatureArray : List16OfOffset16To -{ - template - bool subset (hb_subset_context_t *c, - Iterator coverage, - unsigned class_count, - const hb_map_t *klass_mapping) const - { - TRACE_SUBSET (this); - const hb_set_t &glyphset = *c->plan->glyphset_gsub (); - - auto *out = c->serializer->start_embed (this); - if (unlikely (!c->serializer->extend_min (out))) return_trace (false); - - for (const auto _ : + hb_zip (coverage, *this) - | hb_filter (glyphset, hb_first)) - { - auto *matrix = out->serialize_append (c->serializer); - if (unlikely (!matrix)) return_trace (false); - - const LigatureAttach& src = (this + _.second); - auto indexes = - + hb_range (src.rows * class_count) - | hb_filter ([=] (unsigned index) { return klass_mapping->has (index % class_count); }) - ; - matrix->serialize_subset (c, - _.second, - this, - src.rows, - indexes); - } - return_trace (this->len); - } -}; struct MarkLigPosFormat1 { diff --git a/src/meson.build b/src/meson.build index a7e432afe..4e8c786ae 100644 --- a/src/meson.build +++ b/src/meson.build @@ -113,6 +113,7 @@ hb_base_sources = files( 'OT/Layout/GPOS/CursivePos.hh', 'OT/Layout/GPOS/ExtensionPos.hh', 'OT/Layout/GPOS/GPOS.hh', + 'OT/Layout/GPOS/LigatureArray.hh', 'OT/Layout/GPOS/MarkArray.hh', 'OT/Layout/GPOS/MarkBasePosFormat1.hh', 'OT/Layout/GPOS/MarkBasePos.hh',