[>64k:layout:LigatureSubst] Implement format 2

Implements https://github.com/be-fonts/boring-expansion-spec/issues/33

Subset does NOT lower format.
This commit is contained in:
Behdad Esfahbod 2022-07-06 17:49:56 -06:00
parent 9d0e9faa43
commit ecd8bc5a9c
1 changed files with 12 additions and 0 deletions

View File

@ -14,6 +14,9 @@ struct LigatureSubst
union { union {
HBUINT16 format; /* Format identifier */ HBUINT16 format; /* Format identifier */
LigatureSubstFormat1_2<SmallTypes> format1; LigatureSubstFormat1_2<SmallTypes> format1;
#ifndef HB_NO_BORING_EXPANSION
LigatureSubstFormat1_2<MediumTypes> format2;
#endif
} u; } u;
public: public:
@ -24,10 +27,16 @@ struct LigatureSubst
if (unlikely (!c->may_dispatch (this, &u.format))) return_trace (c->no_dispatch_return_value ()); if (unlikely (!c->may_dispatch (this, &u.format))) return_trace (c->no_dispatch_return_value ());
switch (u.format) { switch (u.format) {
case 1: return_trace (c->dispatch (u.format1, std::forward<Ts> (ds)...)); case 1: return_trace (c->dispatch (u.format1, std::forward<Ts> (ds)...));
#ifndef HB_NO_BORING_EXPANSION
case 2: return_trace (c->dispatch (u.format2, std::forward<Ts> (ds)...));
#endif
default:return_trace (c->default_return_value ()); default:return_trace (c->default_return_value ());
} }
} }
/* TODO This function is only used by small GIDs, and not updated to 24bit GIDs. Should
* be done by using iterators. While at it perhaps using iterator of arrays of hb_codepoint_t
* instead. */
bool serialize (hb_serialize_context_t *c, bool serialize (hb_serialize_context_t *c,
hb_sorted_array_t<const HBGlyphID16> first_glyphs, hb_sorted_array_t<const HBGlyphID16> first_glyphs,
hb_array_t<const unsigned int> ligature_per_first_glyph_count_list, hb_array_t<const unsigned int> ligature_per_first_glyph_count_list,
@ -49,6 +58,9 @@ struct LigatureSubst
default:return_trace (false); default:return_trace (false);
} }
} }
/* TODO subset() should choose format. */
}; };