| 1 | #ifndef OT_LAYOUT_GSUB_ALTERNATESUBST_HH |
| 2 | #define OT_LAYOUT_GSUB_ALTERNATESUBST_HH |
| 3 | |
| 4 | #include "AlternateSubstFormat1.hh" |
| 5 | #include "Common.hh" |
| 6 | |
| 7 | namespace OT { |
| 8 | namespace Layout { |
| 9 | namespace GSUB_impl { |
| 10 | |
| 11 | struct AlternateSubst |
| 12 | { |
| 13 | protected: |
| 14 | union { |
| 15 | HBUINT16 format; /* Format identifier */ |
| 16 | AlternateSubstFormat1_2<SmallTypes> format1; |
| 17 | #ifndef HB_NO_BEYOND_64K |
| 18 | AlternateSubstFormat1_2<MediumTypes> format2; |
| 19 | #endif |
| 20 | } u; |
| 21 | public: |
| 22 | |
| 23 | template <typename context_t, typename ...Ts> |
| 24 | typename context_t::return_t dispatch (context_t *c, Ts&&... ds) const |
| 25 | { |
| 26 | if (unlikely (!c->may_dispatch (this, &u.format))) return c->no_dispatch_return_value (); |
| 27 | TRACE_DISPATCH (this, u.format); |
| 28 | switch (u.format) { |
| 29 | case 1: return_trace (c->dispatch (u.format1, std::forward<Ts> (ds)...)); |
| 30 | #ifndef HB_NO_BEYOND_64K |
| 31 | case 2: return_trace (c->dispatch (u.format2, std::forward<Ts> (ds)...)); |
| 32 | #endif |
| 33 | default:return_trace (c->default_return_value ()); |
| 34 | } |
| 35 | } |
| 36 | |
| 37 | /* TODO This function is unused and not updated to 24bit GIDs. Should be done by using |
| 38 | * iterators. While at it perhaps using iterator of arrays of hb_codepoint_t instead. */ |
| 39 | bool serialize (hb_serialize_context_t *c, |
| 40 | hb_sorted_array_t<const HBGlyphID16> glyphs, |
| 41 | hb_array_t<const unsigned int> alternate_len_list, |
| 42 | hb_array_t<const HBGlyphID16> alternate_glyphs_list) |
| 43 | { |
| 44 | TRACE_SERIALIZE (this); |
| 45 | if (unlikely (!c->extend_min (u.format))) return_trace (false); |
| 46 | unsigned int format = 1; |
| 47 | u.format = format; |
| 48 | switch (u.format) { |
| 49 | case 1: return_trace (u.format1.serialize (c, glyphs, alternate_len_list, alternate_glyphs_list)); |
| 50 | default:return_trace (false); |
| 51 | } |
| 52 | } |
| 53 | |
| 54 | /* TODO subset() should choose format. */ |
| 55 | |
| 56 | }; |
| 57 | |
| 58 | } |
| 59 | } |
| 60 | } |
| 61 | |
| 62 | #endif /* OT_LAYOUT_GSUB_ALTERNATESUBST_HH */ |
| 63 | |