[subset] Wire up subset() call down to subtables

pull/1151/head
Behdad Esfahbod 6 years ago
parent 7b2ef551da
commit 339d3603b9
  1. 36
      src/hb-ot-layout-common.hh
  2. 67
      src/hb-ot-layout-gpos-table.hh
  3. 54
      src/hb-ot-layout-gsub-table.hh
  4. 42
      src/hb-ot-layout-gsubgpos.hh

@ -702,6 +702,42 @@ struct Lookup
return_trace (true); return_trace (true);
} }
template <typename TSubTable>
inline bool subset (hb_subset_context_t *c) const
{
TRACE_SUBSET (this);
struct Lookup *out = c->serializer->embed (*this);
if (unlikely (!out)) return_trace (false);
/* Subset the actual subtables. */
/* TODO Drop empty ones, either by calling intersects() beforehand,
* or just dropping null offsets after. */
const OffsetArrayOf<TSubTable>& subtables = get_subtables<TSubTable> ();
OffsetArrayOf<TSubTable>& out_subtables = out->get_subtables<TSubTable> ();
unsigned int count = subTable.len;
for (unsigned int i = 0; i < count; i++)
{
struct Wrapper
{
inline Wrapper (const TSubTable &subtable_,
unsigned int lookup_type_) :
subtable (subtable_),
lookup_type (lookup_type_) {}
inline bool subset (hb_subset_context_t *c) const
{ return subtable.dispatch (c, lookup_type); }
private:
const TSubTable &subtable;
unsigned int lookup_type;
} wrapper (this+subtables[i], get_type ());
out_subtables[i].serialize_subset (c, wrapper, out);
}
return_trace (true);
}
template <typename TSubTable> template <typename TSubTable>
inline bool sanitize (hb_sanitize_context_t *c) const inline bool sanitize (hb_sanitize_context_t *c) const
{ {

@ -484,6 +484,13 @@ struct SinglePosFormat1
return_trace (true); return_trace (true);
} }
inline bool subset (hb_subset_context_t *c) const
{
TRACE_SUBSET (this);
// TODO(subset)
return_trace (false);
}
inline bool sanitize (hb_sanitize_context_t *c) const inline bool sanitize (hb_sanitize_context_t *c) const
{ {
TRACE_SANITIZE (this); TRACE_SANITIZE (this);
@ -537,6 +544,13 @@ struct SinglePosFormat2
return_trace (true); return_trace (true);
} }
inline bool subset (hb_subset_context_t *c) const
{
TRACE_SUBSET (this);
// TODO(subset)
return_trace (false);
}
inline bool sanitize (hb_sanitize_context_t *c) const inline bool sanitize (hb_sanitize_context_t *c) const
{ {
TRACE_SANITIZE (this); TRACE_SANITIZE (this);
@ -742,6 +756,13 @@ struct PairPosFormat1
return_trace ((this+pairSet[index]).apply (c, valueFormat, skippy_iter.idx)); return_trace ((this+pairSet[index]).apply (c, valueFormat, skippy_iter.idx));
} }
inline bool subset (hb_subset_context_t *c) const
{
TRACE_SUBSET (this);
// TODO(subset)
return_trace (false);
}
inline bool sanitize (hb_sanitize_context_t *c) const inline bool sanitize (hb_sanitize_context_t *c) const
{ {
TRACE_SANITIZE (this); TRACE_SANITIZE (this);
@ -828,6 +849,13 @@ struct PairPosFormat2
return_trace (true); return_trace (true);
} }
inline bool subset (hb_subset_context_t *c) const
{
TRACE_SUBSET (this);
// TODO(subset)
return_trace (false);
}
inline bool sanitize (hb_sanitize_context_t *c) const inline bool sanitize (hb_sanitize_context_t *c) const
{ {
TRACE_SANITIZE (this); TRACE_SANITIZE (this);
@ -1040,6 +1068,13 @@ struct CursivePosFormat1
return_trace (true); return_trace (true);
} }
inline bool subset (hb_subset_context_t *c) const
{
TRACE_SUBSET (this);
// TODO(subset)
return_trace (false);
}
inline bool sanitize (hb_sanitize_context_t *c) const inline bool sanitize (hb_sanitize_context_t *c) const
{ {
TRACE_SANITIZE (this); TRACE_SANITIZE (this);
@ -1140,6 +1175,13 @@ struct MarkBasePosFormat1
return_trace ((this+markArray).apply (c, mark_index, base_index, this+baseArray, classCount, skippy_iter.idx)); return_trace ((this+markArray).apply (c, mark_index, base_index, this+baseArray, classCount, skippy_iter.idx));
} }
inline bool subset (hb_subset_context_t *c) const
{
TRACE_SUBSET (this);
// TODO(subset)
return_trace (false);
}
inline bool sanitize (hb_sanitize_context_t *c) const inline bool sanitize (hb_sanitize_context_t *c) const
{ {
TRACE_SANITIZE (this); TRACE_SANITIZE (this);
@ -1259,6 +1301,13 @@ struct MarkLigPosFormat1
return_trace ((this+markArray).apply (c, mark_index, comp_index, lig_attach, classCount, j)); return_trace ((this+markArray).apply (c, mark_index, comp_index, lig_attach, classCount, j));
} }
inline bool subset (hb_subset_context_t *c) const
{
TRACE_SUBSET (this);
// TODO(subset)
return_trace (false);
}
inline bool sanitize (hb_sanitize_context_t *c) const inline bool sanitize (hb_sanitize_context_t *c) const
{ {
TRACE_SANITIZE (this); TRACE_SANITIZE (this);
@ -1375,6 +1424,13 @@ struct MarkMarkPosFormat1
return_trace ((this+mark1Array).apply (c, mark1_index, mark2_index, this+mark2Array, classCount, j)); return_trace ((this+mark1Array).apply (c, mark1_index, mark2_index, this+mark2Array, classCount, j));
} }
inline bool subset (hb_subset_context_t *c) const
{
TRACE_SUBSET (this);
// TODO(subset)
return_trace (false);
}
inline bool sanitize (hb_sanitize_context_t *c) const inline bool sanitize (hb_sanitize_context_t *c) const
{ {
TRACE_SANITIZE (this); TRACE_SANITIZE (this);
@ -1543,6 +1599,9 @@ struct PosLookup : Lookup
inline typename context_t::return_t dispatch (context_t *c) const inline typename context_t::return_t dispatch (context_t *c) const
{ return Lookup::dispatch<SubTable> (c); } { return Lookup::dispatch<SubTable> (c); }
inline bool subset (hb_subset_context_t *c) const
{ return Lookup::subset<SubTable> (c); }
inline bool sanitize (hb_sanitize_context_t *c) const inline bool sanitize (hb_sanitize_context_t *c) const
{ return Lookup::sanitize<SubTable> (c); } { return Lookup::sanitize<SubTable> (c); }
}; };
@ -1563,11 +1622,11 @@ struct GPOS : GSUBGPOS
static inline void position_finish_advances (hb_font_t *font, hb_buffer_t *buffer); static inline void position_finish_advances (hb_font_t *font, hb_buffer_t *buffer);
static inline void position_finish_offsets (hb_font_t *font, hb_buffer_t *buffer); static inline void position_finish_offsets (hb_font_t *font, hb_buffer_t *buffer);
inline bool subset (hb_subset_context_t *c) const
{ return GSUBGPOS::subset<PosLookup> (c); }
inline bool sanitize (hb_sanitize_context_t *c) const inline bool sanitize (hb_sanitize_context_t *c) const
{ { return GSUBGPOS::sanitize<PosLookup> (c); }
TRACE_SANITIZE (this);
return_trace (GSUBGPOS::sanitize<PosLookup> (c));
}
typedef GSUBGPOS::accelerator_t<GPOS> accelerator_t; typedef GSUBGPOS::accelerator_t<GPOS> accelerator_t;
}; };

@ -102,6 +102,13 @@ struct SingleSubstFormat1
return_trace (true); return_trace (true);
} }
inline bool subset (hb_subset_context_t *c) const
{
TRACE_SUBSET (this);
// TODO(subset)
return_trace (false);
}
inline bool sanitize (hb_sanitize_context_t *c) const inline bool sanitize (hb_sanitize_context_t *c) const
{ {
TRACE_SANITIZE (this); TRACE_SANITIZE (this);
@ -184,6 +191,13 @@ struct SingleSubstFormat2
return_trace (true); return_trace (true);
} }
inline bool subset (hb_subset_context_t *c) const
{
TRACE_SUBSET (this);
// TODO(subset)
return_trace (false);
}
inline bool sanitize (hb_sanitize_context_t *c) const inline bool sanitize (hb_sanitize_context_t *c) const
{ {
TRACE_SANITIZE (this); TRACE_SANITIZE (this);
@ -387,6 +401,13 @@ struct MultipleSubstFormat1
return_trace (true); return_trace (true);
} }
inline bool subset (hb_subset_context_t *c) const
{
TRACE_SUBSET (this);
// TODO(subset)
return_trace (false);
}
inline bool sanitize (hb_sanitize_context_t *c) const inline bool sanitize (hb_sanitize_context_t *c) const
{ {
TRACE_SANITIZE (this); TRACE_SANITIZE (this);
@ -570,6 +591,13 @@ struct AlternateSubstFormat1
return_trace (true); return_trace (true);
} }
inline bool subset (hb_subset_context_t *c) const
{
TRACE_SUBSET (this);
// TODO(subset)
return_trace (false);
}
inline bool sanitize (hb_sanitize_context_t *c) const inline bool sanitize (hb_sanitize_context_t *c) const
{ {
TRACE_SANITIZE (this); TRACE_SANITIZE (this);
@ -911,6 +939,13 @@ struct LigatureSubstFormat1
return_trace (true); return_trace (true);
} }
inline bool subset (hb_subset_context_t *c) const
{
TRACE_SUBSET (this);
// TODO(subset)
return_trace (false);
}
inline bool sanitize (hb_sanitize_context_t *c) const inline bool sanitize (hb_sanitize_context_t *c) const
{ {
TRACE_SANITIZE (this); TRACE_SANITIZE (this);
@ -1101,6 +1136,13 @@ struct ReverseChainSingleSubstFormat1
return_trace (false); return_trace (false);
} }
inline bool subset (hb_subset_context_t *c) const
{
TRACE_SUBSET (this);
// TODO(subset)
return_trace (false);
}
inline bool sanitize (hb_sanitize_context_t *c) const inline bool sanitize (hb_sanitize_context_t *c) const
{ {
TRACE_SANITIZE (this); TRACE_SANITIZE (this);
@ -1367,7 +1409,7 @@ struct SubstLookup : Lookup
{ return Lookup::dispatch<SubTable> (c); } { return Lookup::dispatch<SubTable> (c); }
inline bool subset (hb_subset_context_t *c) const inline bool subset (hb_subset_context_t *c) const
{ return false; }//XXX Lookup::subset<SubTable> (c); } { return Lookup::subset<SubTable> (c); }
inline bool sanitize (hb_sanitize_context_t *c) const inline bool sanitize (hb_sanitize_context_t *c) const
{ return Lookup::sanitize<SubTable> (c); } { return Lookup::sanitize<SubTable> (c); }
@ -1386,16 +1428,10 @@ struct GSUB : GSUBGPOS
{ return CastR<SubstLookup> (GSUBGPOS::get_lookup (i)); } { return CastR<SubstLookup> (GSUBGPOS::get_lookup (i)); }
inline bool subset (hb_subset_context_t *c) const inline bool subset (hb_subset_context_t *c) const
{ { return GSUBGPOS::subset<SubstLookup> (c); }
TRACE_SUBSET (this);
return_trace (GSUBGPOS::subset<SubstLookup> (c));
}
inline bool sanitize (hb_sanitize_context_t *c) const inline bool sanitize (hb_sanitize_context_t *c) const
{ { return GSUBGPOS::sanitize<SubstLookup> (c); }
TRACE_SANITIZE (this);
return_trace (GSUBGPOS::sanitize<SubstLookup> (c));
}
typedef GSUBGPOS::accelerator_t<GSUB> accelerator_t; typedef GSUBGPOS::accelerator_t<GSUB> accelerator_t;
}; };

@ -1435,6 +1435,13 @@ struct ContextFormat1
return_trace (rule_set.apply (c, lookup_context)); return_trace (rule_set.apply (c, lookup_context));
} }
inline bool subset (hb_subset_context_t *c) const
{
TRACE_SUBSET (this);
// TODO(subset)
return_trace (false);
}
inline bool sanitize (hb_sanitize_context_t *c) const inline bool sanitize (hb_sanitize_context_t *c) const
{ {
TRACE_SANITIZE (this); TRACE_SANITIZE (this);
@ -1547,6 +1554,13 @@ struct ContextFormat2
return_trace (rule_set.apply (c, lookup_context)); return_trace (rule_set.apply (c, lookup_context));
} }
inline bool subset (hb_subset_context_t *c) const
{
TRACE_SUBSET (this);
// TODO(subset)
return_trace (false);
}
inline bool sanitize (hb_sanitize_context_t *c) const inline bool sanitize (hb_sanitize_context_t *c) const
{ {
TRACE_SANITIZE (this); TRACE_SANITIZE (this);
@ -1648,6 +1662,13 @@ struct ContextFormat3
return_trace (context_apply_lookup (c, glyphCount, (const HBUINT16 *) (coverageZ + 1), lookupCount, lookupRecord, lookup_context)); return_trace (context_apply_lookup (c, glyphCount, (const HBUINT16 *) (coverageZ + 1), lookupCount, lookupRecord, lookup_context));
} }
inline bool subset (hb_subset_context_t *c) const
{
TRACE_SUBSET (this);
// TODO(subset)
return_trace (false);
}
inline bool sanitize (hb_sanitize_context_t *c) const inline bool sanitize (hb_sanitize_context_t *c) const
{ {
TRACE_SANITIZE (this); TRACE_SANITIZE (this);
@ -2076,6 +2097,13 @@ struct ChainContextFormat1
return_trace (rule_set.apply (c, lookup_context)); return_trace (rule_set.apply (c, lookup_context));
} }
inline bool subset (hb_subset_context_t *c) const
{
TRACE_SUBSET (this);
// TODO(subset)
return_trace (false);
}
inline bool sanitize (hb_sanitize_context_t *c) const inline bool sanitize (hb_sanitize_context_t *c) const
{ {
TRACE_SANITIZE (this); TRACE_SANITIZE (this);
@ -2209,6 +2237,13 @@ struct ChainContextFormat2
return_trace (rule_set.apply (c, lookup_context)); return_trace (rule_set.apply (c, lookup_context));
} }
inline bool subset (hb_subset_context_t *c) const
{
TRACE_SUBSET (this);
// TODO(subset)
return_trace (false);
}
inline bool sanitize (hb_sanitize_context_t *c) const inline bool sanitize (hb_sanitize_context_t *c) const
{ {
TRACE_SANITIZE (this); TRACE_SANITIZE (this);
@ -2352,6 +2387,13 @@ struct ChainContextFormat3
lookup.len, lookup.arrayZ, lookup_context)); lookup.len, lookup.arrayZ, lookup_context));
} }
inline bool subset (hb_subset_context_t *c) const
{
TRACE_SUBSET (this);
// TODO(subset)
return_trace (false);
}
inline bool sanitize (hb_sanitize_context_t *c) const inline bool sanitize (hb_sanitize_context_t *c) const
{ {
TRACE_SANITIZE (this); TRACE_SANITIZE (this);

Loading…
Cancel
Save