[>64k:layout] Templatize AlternateSet

This commit is contained in:
Behdad Esfahbod 2022-07-06 14:03:45 -06:00
parent a58a48622a
commit c53d3ad51e
3 changed files with 11 additions and 9 deletions

View File

@ -7,10 +7,11 @@ namespace OT {
namespace Layout { namespace Layout {
namespace GSUB_impl { namespace GSUB_impl {
template <typename Types>
struct AlternateSet struct AlternateSet
{ {
protected: protected:
Array16Of<HBGlyphID16> Array16Of<typename Types::HBGlyphID>
alternates; /* Array of alternate GlyphIDs--in alternates; /* Array of alternate GlyphIDs--in
* arbitrary order */ * arbitrary order */
public: public:

View File

@ -13,7 +13,7 @@ struct AlternateSubst
protected: protected:
union { union {
HBUINT16 format; /* Format identifier */ HBUINT16 format; /* Format identifier */
AlternateSubstFormat1 format1; AlternateSubstFormat1_2<SmallTypes> format1;
} u; } u;
public: public:

View File

@ -8,18 +8,19 @@ namespace OT {
namespace Layout { namespace Layout {
namespace GSUB_impl { namespace GSUB_impl {
struct AlternateSubstFormat1 template <typename Types>
struct AlternateSubstFormat1_2
{ {
protected: protected:
HBUINT16 format; /* Format identifier--format = 1 */ HBUINT16 format; /* Format identifier--format = 1 */
Offset16To<Coverage> typename Types::template OffsetTo<Coverage>
coverage; /* Offset to Coverage table--from coverage; /* Offset to Coverage table--from
* beginning of Substitution table */ * beginning of Substitution table */
Array16OfOffset16To<AlternateSet> Array16Of<typename Types::template OffsetTo<AlternateSet<Types>>>
alternateSet; /* Array of AlternateSet tables alternateSet; /* Array of AlternateSet tables
* ordered by Coverage Index */ * ordered by Coverage Index */
public: public:
DEFINE_SIZE_ARRAY (6, alternateSet); DEFINE_SIZE_ARRAY (2 + 2 * Types::size, alternateSet);
bool sanitize (hb_sanitize_context_t *c) const bool sanitize (hb_sanitize_context_t *c) const
{ {
@ -39,7 +40,7 @@ struct AlternateSubstFormat1
| hb_filter (c->parent_active_glyphs (), hb_first) | hb_filter (c->parent_active_glyphs (), hb_first)
| hb_map (hb_second) | hb_map (hb_second)
| hb_map (hb_add (this)) | hb_map (hb_add (this))
| hb_apply ([c] (const AlternateSet &_) { _.closure (c); }) | hb_apply ([c] (const AlternateSet<Types> &_) { _.closure (c); })
; ;
} }
@ -52,7 +53,7 @@ struct AlternateSubstFormat1
+ hb_zip (this+coverage, alternateSet) + hb_zip (this+coverage, alternateSet)
| hb_map (hb_second) | hb_map (hb_second)
| hb_map (hb_add (this)) | hb_map (hb_add (this))
| hb_apply ([c] (const AlternateSet &_) { _.collect_glyphs (c); }) | hb_apply ([c] (const AlternateSet<Types> &_) { _.collect_glyphs (c); })
; ;
} }