MultipleSubst.hh (1527B)
1 #ifndef OT_LAYOUT_GSUB_MULTIPLESUBST_HH 2 #define OT_LAYOUT_GSUB_MULTIPLESUBST_HH 3 4 #include "Common.hh" 5 #include "MultipleSubstFormat1.hh" 6 7 namespace OT { 8 namespace Layout { 9 namespace GSUB_impl { 10 11 struct MultipleSubst 12 { 13 protected: 14 union { 15 struct { HBUINT16 v; } format; /* Format identifier */ 16 MultipleSubstFormat1_2<SmallTypes> format1; 17 #ifndef HB_NO_BEYOND_64K 18 MultipleSubstFormat1_2<MediumTypes> format2; 19 #endif 20 } u; 21 22 public: 23 24 template <typename context_t, typename ...Ts> 25 typename context_t::return_t dispatch (context_t *c, Ts&&... ds) const 26 { 27 if (unlikely (!c->may_dispatch (this, &u.format.v))) return c->no_dispatch_return_value (); 28 TRACE_DISPATCH (this, u.format.v); 29 switch (u.format.v) { 30 case 1: return_trace (c->dispatch (u.format1, std::forward<Ts> (ds)...)); 31 #ifndef HB_NO_BEYOND_64K 32 case 2: return_trace (c->dispatch (u.format2, std::forward<Ts> (ds)...)); 33 #endif 34 default:return_trace (c->default_return_value ()); 35 } 36 } 37 38 template<typename Iterator, 39 hb_requires (hb_is_sorted_iterator (Iterator))> 40 bool serialize (hb_serialize_context_t *c, 41 Iterator it) 42 { 43 TRACE_SERIALIZE (this); 44 if (unlikely (!c->extend_min (u.format.v))) return_trace (false); 45 unsigned int format = 1; 46 u.format.v = format; 47 switch (u.format.v) { 48 case 1: return_trace (u.format1.serialize (c, it)); 49 default:return_trace (false); 50 } 51 } 52 53 /* TODO subset() should choose format. */ 54 55 }; 56 57 58 } 59 } 60 } 61 62 #endif /* OT_LAYOUT_GSUB_MULTIPLESUBST_HH */