From 9c3747c5e50423e0a7202f249728d5c5b2b09073 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Mon, 3 Sep 2018 16:53:03 -0700 Subject: [PATCH] [subset] More --- src/hb-ot-layout-gpos-table.hh | 10 +++++---- src/hb-ot-layout-gsub-table.hh | 48 +++++++++++++++++++++--------------------- src/hb-ot-layout-gsubgpos.hh | 22 +++++++++++++------ 3 files changed, 45 insertions(+), 35 deletions(-) diff --git a/src/hb-ot-layout-gpos-table.hh b/src/hb-ot-layout-gpos-table.hh index f088061..3ff72e3 100644 --- a/src/hb-ot-layout-gpos-table.hh +++ b/src/hb-ot-layout-gpos-table.hh @@ -1433,7 +1433,7 @@ struct ChainContextPos : ChainContext {}; struct ExtensionPos : Extension { - typedef struct PosLookupSubTable LookupSubTable; + typedef struct PosLookupSubTable SubTable; }; @@ -1498,8 +1498,10 @@ struct PosLookupSubTable struct PosLookup : Lookup { - inline const PosLookupSubTable& get_subtable (unsigned int i) const - { return Lookup::get_subtable (i); } + typedef struct PosLookupSubTable SubTable; + + inline const SubTable& get_subtable (unsigned int i) const + { return Lookup::get_subtable (i); } inline bool is_reverse (void) const { @@ -1538,7 +1540,7 @@ struct PosLookup : Lookup template inline typename context_t::return_t dispatch (context_t *c) const - { return Lookup::dispatch (c); } + { return Lookup::dispatch (c); } inline bool sanitize (hb_sanitize_context_t *c) const { diff --git a/src/hb-ot-layout-gsub-table.hh b/src/hb-ot-layout-gsub-table.hh index 31e3c2f..a77ab4c 100644 --- a/src/hb-ot-layout-gsub-table.hh +++ b/src/hb-ot-layout-gsub-table.hh @@ -980,7 +980,7 @@ struct ChainContextSubst : ChainContext {}; struct ExtensionSubst : Extension { - typedef struct SubstLookupSubTable LookupSubTable; + typedef struct SubstLookupSubTable SubTable; inline bool is_reverse (void) const; }; @@ -1211,16 +1211,18 @@ struct SubstLookupSubTable struct SubstLookup : Lookup { - inline const SubstLookupSubTable& get_subtable (unsigned int i) const - { return Lookup::get_subtable (i); } + typedef SubstLookupSubTable SubTable; + + inline const SubTable& get_subtable (unsigned int i) const + { return Lookup::get_subtable (i); } inline static bool lookup_type_is_reverse (unsigned int lookup_type) - { return lookup_type == SubstLookupSubTable::ReverseChainSingle; } + { return lookup_type == SubTable::ReverseChainSingle; } inline bool is_reverse (void) const { unsigned int type = get_type (); - if (unlikely (type == SubstLookupSubTable::Extension)) + if (unlikely (type == SubTable::Extension)) return CastR (get_subtable(0)).is_reverse (); return lookup_type_is_reverse (type); } @@ -1277,9 +1279,9 @@ struct SubstLookup : Lookup static bool apply_recurse_func (hb_ot_apply_context_t *c, unsigned int lookup_index); - inline SubstLookupSubTable& serialize_subtable (hb_serialize_context_t *c, - unsigned int i) - { return get_subtables ()[i].serialize (c, this); } + inline SubTable& serialize_subtable (hb_serialize_context_t *c, + unsigned int i) + { return get_subtables ()[i].serialize (c, this); } inline bool serialize_single (hb_serialize_context_t *c, uint32_t lookup_props, @@ -1288,7 +1290,7 @@ struct SubstLookup : Lookup unsigned int num_glyphs) { TRACE_SERIALIZE (this); - if (unlikely (!Lookup::serialize (c, SubstLookupSubTable::Single, lookup_props, 1))) return_trace (false); + if (unlikely (!Lookup::serialize (c, SubTable::Single, lookup_props, 1))) return_trace (false); return_trace (serialize_subtable (c, 0).u.single.serialize (c, glyphs, substitutes, num_glyphs)); } @@ -1300,7 +1302,7 @@ struct SubstLookup : Lookup Supplier &substitute_glyphs_list) { TRACE_SERIALIZE (this); - if (unlikely (!Lookup::serialize (c, SubstLookupSubTable::Multiple, lookup_props, 1))) return_trace (false); + if (unlikely (!Lookup::serialize (c, SubTable::Multiple, lookup_props, 1))) return_trace (false); return_trace (serialize_subtable (c, 0).u.multiple.serialize (c, glyphs, substitute_len_list, @@ -1316,7 +1318,7 @@ struct SubstLookup : Lookup Supplier &alternate_glyphs_list) { TRACE_SERIALIZE (this); - if (unlikely (!Lookup::serialize (c, SubstLookupSubTable::Alternate, lookup_props, 1))) return_trace (false); + if (unlikely (!Lookup::serialize (c, SubTable::Alternate, lookup_props, 1))) return_trace (false); return_trace (serialize_subtable (c, 0).u.alternate.serialize (c, glyphs, alternate_len_list, @@ -1334,7 +1336,7 @@ struct SubstLookup : Lookup Supplier &component_list /* Starting from second for each ligature */) { TRACE_SERIALIZE (this); - if (unlikely (!Lookup::serialize (c, SubstLookupSubTable::Ligature, lookup_props, 1))) return_trace (false); + if (unlikely (!Lookup::serialize (c, SubTable::Ligature, lookup_props, 1))) return_trace (false); return_trace (serialize_subtable (c, 0).u.ligature.serialize (c, first_glyphs, ligature_per_first_glyph_count_list, @@ -1361,7 +1363,12 @@ struct SubstLookup : Lookup template inline typename context_t::return_t dispatch (context_t *c) const - { return Lookup::dispatch (c); } + { return Lookup::dispatch (c); } + + inline bool subset (hb_subset_context_t *c) const + { + return false; //XXX + } inline bool sanitize (hb_sanitize_context_t *c) const { @@ -1369,7 +1376,7 @@ struct SubstLookup : Lookup if (unlikely (!Lookup::sanitize (c))) return_trace (false); if (unlikely (!dispatch (c))) return_trace (false); - if (unlikely (get_type () == SubstLookupSubTable::Extension)) + if (unlikely (get_type () == SubTable::Extension)) { /* The spec says all subtables of an Extension lookup should * have the same type, which shall not be the Extension type @@ -1400,14 +1407,7 @@ struct GSUB : GSUBGPOS inline bool subset (hb_subset_context_t *c) const { TRACE_SUBSET (this); - //struct GSUB *out = c->serializer->start_embed (); - if (unlikely (!GSUBGPOS::subset (c))) return_trace (false); - //const OffsetTo &list = CastR > (lookupList); - //OffsetTo &outList = CastR > (out->lookupList); - //outList.set (0); - //outList.serialize_subset (c, this+list, out); - /* TODO Use intersects() to count how many subtables survive? */ - return_trace (true); + return_trace (GSUBGPOS::subset (c)); } inline bool sanitize (hb_sanitize_context_t *c) const @@ -1425,8 +1425,8 @@ struct GSUB : GSUBGPOS /*static*/ inline bool ExtensionSubst::is_reverse (void) const { unsigned int type = get_type (); - if (unlikely (type == SubstLookupSubTable::Extension)) - return CastR (get_subtable()).is_reverse (); + if (unlikely (type == SubTable::Extension)) + return CastR (get_subtable()).is_reverse (); return SubstLookup::lookup_type_is_reverse (type); } diff --git a/src/hb-ot-layout-gsubgpos.hh b/src/hb-ot-layout-gsubgpos.hh index e32bbd5..5ccc5fe 100644 --- a/src/hb-ot-layout-gsubgpos.hh +++ b/src/hb-ot-layout-gsubgpos.hh @@ -2420,8 +2420,8 @@ struct ExtensionFormat1 inline const X& get_subtable (void) const { unsigned int offset = extensionOffset; - if (unlikely (!offset)) return Null(typename T::LookupSubTable); - return StructAtOffset (this, offset); + if (unlikely (!offset)) return Null(typename T::SubTable); + return StructAtOffset (this, offset); } template @@ -2429,7 +2429,7 @@ struct ExtensionFormat1 { TRACE_DISPATCH (this, format); if (unlikely (!c->may_dispatch (this, this))) return_trace (c->no_dispatch_return_value ()); - return_trace (get_subtable ().dispatch (c, get_type ())); + return_trace (get_subtable ().dispatch (c, get_type ())); } /* This is called from may_dispatch() above with hb_sanitize_context_t. */ @@ -2438,7 +2438,7 @@ struct ExtensionFormat1 TRACE_SANITIZE (this); return_trace (c->check_struct (this) && extensionOffset != 0 && - extensionLookupType != T::LookupSubTable::Extension); + extensionLookupType != T::SubTable::Extension); } protected: @@ -2466,8 +2466,8 @@ struct Extension inline const X& get_subtable (void) const { switch (u.format) { - case 1: return u.format1.template get_subtable (); - default:return Null(typename T::LookupSubTable); + case 1: return u.format1.template get_subtable (); + default:return Null(typename T::SubTable); } } @@ -2546,6 +2546,7 @@ struct GSUBGPOS return get_feature (feature_index); } + template inline bool subset (hb_subset_context_t *c) const { TRACE_SUBSET (this); @@ -2553,7 +2554,14 @@ struct GSUBGPOS if (unlikely (!out)) return_trace (false); out->scriptList.serialize_subset (c, this+scriptList, out); out->featureList.serialize_subset (c, this+featureList, out); - out->lookupList.set (0); /* GSUB/GPOS fill this one in. */ + + typedef OffsetListOf TLookupList; + /* TODO Use intersects() to count how many subtables survive? */ + CastR > (out->lookupList) + .serialize_subset (c, + this+CastR > (lookupList), + out); + if (version.to_int () >= 0x00010001u) out->featureVars.serialize_subset (c, this+featureVars, out); return_trace (true); -- 2.7.4