removed default base; replaced w/ bias if required
This commit is contained in:
parent
4c3af7d406
commit
188a0a47c2
@ -316,7 +316,6 @@ struct OffsetTo : Offset<OffsetType, has_null>
|
||||
bool serialize_subset (hb_subset_context_t *c,
|
||||
const OffsetTo& src,
|
||||
const void *src_base,
|
||||
const void *dst_base,
|
||||
Ts&&... ds)
|
||||
{
|
||||
*this = 0;
|
||||
@ -330,7 +329,7 @@ struct OffsetTo : Offset<OffsetType, has_null>
|
||||
bool ret = c->dispatch (src_base+src, hb_forward<Ts> (ds)...);
|
||||
|
||||
if (ret || !has_null)
|
||||
s->add_link (*this, s->pop_pack (), dst_base);
|
||||
s->add_link (*this, s->pop_pack ());
|
||||
else
|
||||
s->pop_discard ();
|
||||
|
||||
@ -345,7 +344,7 @@ struct OffsetTo : Offset<OffsetType, has_null>
|
||||
bool serialize_copy (hb_serialize_context_t *c,
|
||||
const OffsetTo& src,
|
||||
const void *src_base,
|
||||
const void *dst_base,
|
||||
unsigned dst_bias,
|
||||
hb_serialize_context_t::whence_t whence,
|
||||
Ts&&... ds)
|
||||
{
|
||||
@ -357,7 +356,7 @@ struct OffsetTo : Offset<OffsetType, has_null>
|
||||
|
||||
bool ret = c->copy (src_base+src, hb_forward<Ts> (ds)...);
|
||||
|
||||
c->add_link (*this, c->pop_pack (), dst_base, whence);
|
||||
c->add_link (*this, c->pop_pack (), whence, dst_bias);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@ -365,8 +364,8 @@ struct OffsetTo : Offset<OffsetType, has_null>
|
||||
bool serialize_copy (hb_serialize_context_t *c,
|
||||
const OffsetTo& src,
|
||||
const void *src_base,
|
||||
const void *dst_base)
|
||||
{ return serialize_copy (c, src, src_base, dst_base, hb_serialize_context_t::Head); }
|
||||
unsigned dst_bias = 0)
|
||||
{ return serialize_copy (c, src, src_base, dst_bias, hb_serialize_context_t::Head); }
|
||||
|
||||
bool sanitize_shallow (hb_sanitize_context_t *c, const void *base) const
|
||||
{
|
||||
|
@ -892,8 +892,7 @@ struct VariationSelectorRecord
|
||||
const hb_set_t *unicodes,
|
||||
const hb_set_t *glyphs,
|
||||
const hb_map_t *glyph_map,
|
||||
const void *src_base,
|
||||
const void *dst_base) const
|
||||
const void *src_base) const
|
||||
{
|
||||
auto snap = c->snapshot ();
|
||||
auto *out = c->embed<VariationSelectorRecord> (*this);
|
||||
@ -985,7 +984,7 @@ struct CmapSubtableFormat14
|
||||
for (int i = src_tbl->record.len - 1; i >= 0; i--)
|
||||
{
|
||||
hb_pair_t<unsigned, unsigned> result =
|
||||
src_tbl->record[i].copy (c, unicodes, glyphs, glyph_map, src_base, this);
|
||||
src_tbl->record[i].copy (c, unicodes, glyphs, glyph_map, src_base);
|
||||
if (result.first || result.second)
|
||||
obj_indices.push (result);
|
||||
}
|
||||
@ -1026,8 +1025,8 @@ struct CmapSubtableFormat14
|
||||
* are for the variation record at record[j].
|
||||
*/
|
||||
int j = obj_indices.length - 1 - i;
|
||||
c->add_link (record[j].defaultUVS, obj_indices[i].first, this);
|
||||
c->add_link (record[j].nonDefaultUVS, obj_indices[i].second, this);
|
||||
c->add_link (record[j].defaultUVS, obj_indices[i].first);
|
||||
c->add_link (record[j].nonDefaultUVS, obj_indices[i].second);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1170,7 +1169,6 @@ struct EncodingRecord
|
||||
Iterator it,
|
||||
unsigned format,
|
||||
const void *src_base,
|
||||
const void *dst_base,
|
||||
const hb_subset_plan_t *plan,
|
||||
/* INOUT */ unsigned *objidx) const
|
||||
{
|
||||
@ -1195,7 +1193,7 @@ struct EncodingRecord
|
||||
return_trace (nullptr);
|
||||
}
|
||||
|
||||
c->add_link (out->subtable, *objidx, dst_base);
|
||||
c->add_link (out->subtable, *objidx);
|
||||
return_trace (out);
|
||||
}
|
||||
|
||||
@ -1231,9 +1229,9 @@ struct cmap
|
||||
|
||||
unsigned format = (src_base+_.subtable).u.format;
|
||||
|
||||
if (format == 4) c->copy (_, + it | hb_filter (unicodes_set, hb_first), 4u, src_base, this, plan, &format4objidx);
|
||||
else if (format == 12) c->copy (_, + it | hb_filter (unicodes_set, hb_first), 12u, src_base, this, plan, &format12objidx);
|
||||
else if (format == 14) c->copy (_, it, 14u, src_base, this, plan, &format14objidx);
|
||||
if (format == 4) c->copy (_, + it | hb_filter (unicodes_set, hb_first), 4u, src_base, plan, &format4objidx);
|
||||
else if (format == 12) c->copy (_, + it | hb_filter (unicodes_set, hb_first), 12u, src_base, plan, &format12objidx);
|
||||
else if (format == 14) c->copy (_, it, 14u, src_base, plan, &format14objidx);
|
||||
}
|
||||
|
||||
c->check_assign(this->encodingRecord.len, (c->length () - cmap::min_size)/EncodingRecord::static_size);
|
||||
|
@ -584,7 +584,7 @@ struct IndexSubtableArray
|
||||
{
|
||||
IndexSubtableRecord* record = c->serializer->embed (records[i]);
|
||||
if (unlikely (!record)) return_trace (false);
|
||||
c->serializer->add_link (record->offsetToSubtable, objidxs[records.length - 1 - i], dst);
|
||||
c->serializer->add_link (record->offsetToSubtable, objidxs[records.length - 1 - i]);
|
||||
}
|
||||
return_trace (true);
|
||||
}
|
||||
@ -628,7 +628,7 @@ struct BitmapSizeTable
|
||||
}
|
||||
|
||||
bool
|
||||
subset (hb_subset_context_t *c, const void *src_base, const void *dst_base,
|
||||
subset (hb_subset_context_t *c, const void *src_base,
|
||||
const char *cbdt, unsigned int cbdt_length,
|
||||
hb_vector_t<char> *cbdt_prime /* INOUT */) const
|
||||
{
|
||||
@ -648,7 +648,6 @@ struct BitmapSizeTable
|
||||
if (!out_table->indexSubtableArrayOffset.serialize_subset (c,
|
||||
indexSubtableArrayOffset,
|
||||
src_base,
|
||||
dst_base,
|
||||
&bitmap_size_context))
|
||||
return_trace (false);
|
||||
if (!bitmap_size_context.size ||
|
||||
@ -748,7 +747,7 @@ struct CBLC
|
||||
auto snap = c->serializer->snapshot ();
|
||||
auto cbdt_prime_len = cbdt_prime->length;
|
||||
|
||||
if (!table.subset (c, this, cblc_prime, cbdt, cbdt_length, cbdt_prime))
|
||||
if (!table.subset (c, this, cbdt, cbdt_length, cbdt_prime))
|
||||
{
|
||||
cblc_prime->sizeTables.len--;
|
||||
c->serializer->revert (snap);
|
||||
|
@ -340,7 +340,7 @@ struct sbix
|
||||
}
|
||||
|
||||
bool
|
||||
add_strike (hb_subset_context_t *c, const void *dst_base, unsigned i) const
|
||||
add_strike (hb_subset_context_t *c, unsigned i) const
|
||||
{
|
||||
if (strikes[i].is_null () || c->source_blob->length < (unsigned) strikes[i])
|
||||
return false;
|
||||
@ -348,7 +348,7 @@ struct sbix
|
||||
return (this+strikes[i]).subset (c, c->source_blob->length - (unsigned) strikes[i]);
|
||||
}
|
||||
|
||||
bool serialize_strike_offsets (hb_subset_context_t *c, const void *dst_base) const
|
||||
bool serialize_strike_offsets (hb_subset_context_t *c) const
|
||||
{
|
||||
TRACE_SERIALIZE (this);
|
||||
|
||||
@ -365,7 +365,7 @@ struct sbix
|
||||
*o = 0;
|
||||
auto snap = c->serializer->snapshot ();
|
||||
c->serializer->push ();
|
||||
bool ret = add_strike (c, dst_base, i);
|
||||
bool ret = add_strike (c, i);
|
||||
if (!ret)
|
||||
{
|
||||
c->serializer->pop_discard ();
|
||||
@ -379,7 +379,7 @@ struct sbix
|
||||
}
|
||||
}
|
||||
for (unsigned int i = 0; i < new_strikes.length; ++i)
|
||||
c->serializer->add_link (*new_strikes[i], objidxs[new_strikes.length - 1 - i], dst_base);
|
||||
c->serializer->add_link (*new_strikes[i], objidxs[new_strikes.length - 1 - i]);
|
||||
|
||||
return_trace (true);
|
||||
}
|
||||
@ -393,7 +393,7 @@ struct sbix
|
||||
if (unlikely (!c->serializer->embed (this->version))) return_trace (false);
|
||||
if (unlikely (!c->serializer->embed (this->flags))) return_trace (false);
|
||||
|
||||
return_trace (serialize_strike_offsets (c, sbix_prime));
|
||||
return_trace (serialize_strike_offsets (c));
|
||||
}
|
||||
|
||||
protected:
|
||||
|
@ -145,9 +145,8 @@ struct subset_offset_array_t
|
||||
subset_offset_array_t
|
||||
(hb_subset_context_t *subset_context,
|
||||
OutputArray& out,
|
||||
const void *src_base,
|
||||
const void *dest_base)
|
||||
: _subset_context(subset_context), _out (out), _src_base (src_base), _dest_base (dest_base) {}
|
||||
const void *src_base)
|
||||
: _subset_context(subset_context), _out (out), _src_base (src_base) {}
|
||||
|
||||
template <typename T>
|
||||
bool
|
||||
@ -157,7 +156,7 @@ struct subset_offset_array_t
|
||||
auto *o = _out.serialize_append (_subset_context->serializer);
|
||||
if (unlikely (!o)) return false;
|
||||
auto snap = _subset_context->serializer->snapshot ();
|
||||
bool ret = o->serialize_subset (_subset_context, offset, _src_base, _dest_base);
|
||||
bool ret = o->serialize_subset (_subset_context, offset, _src_base);
|
||||
if (!ret)
|
||||
{
|
||||
_out.pop ();
|
||||
@ -170,7 +169,6 @@ struct subset_offset_array_t
|
||||
hb_subset_context_t *_subset_context;
|
||||
OutputArray &_out;
|
||||
const void *_src_base;
|
||||
const void *_dest_base;
|
||||
};
|
||||
|
||||
|
||||
@ -181,9 +179,8 @@ struct subset_offset_array_arg_t
|
||||
(hb_subset_context_t *subset_context,
|
||||
OutputArray& out,
|
||||
const void *src_base,
|
||||
const void *dest_base,
|
||||
Arg &&arg)
|
||||
: _subset_context(subset_context), _out (out), _src_base (src_base), _dest_base (dest_base), _arg (arg) {}
|
||||
: _subset_context(subset_context), _out (out), _src_base (src_base), _arg (arg) {}
|
||||
|
||||
template <typename T>
|
||||
bool
|
||||
@ -193,7 +190,7 @@ struct subset_offset_array_arg_t
|
||||
auto *o = _out.serialize_append (_subset_context->serializer);
|
||||
if (unlikely (!o)) return false;
|
||||
auto snap = _subset_context->serializer->snapshot ();
|
||||
bool ret = o->serialize_subset (_subset_context, offset, _src_base, _dest_base, _arg);
|
||||
bool ret = o->serialize_subset (_subset_context, offset, _src_base, _arg);
|
||||
if (!ret)
|
||||
{
|
||||
_out.pop ();
|
||||
@ -206,7 +203,6 @@ struct subset_offset_array_arg_t
|
||||
hb_subset_context_t *_subset_context;
|
||||
OutputArray &_out;
|
||||
const void *_src_base;
|
||||
const void *_dest_base;
|
||||
Arg &&_arg;
|
||||
};
|
||||
|
||||
@ -222,10 +218,9 @@ struct
|
||||
operator ()
|
||||
(hb_subset_context_t *subset_context,
|
||||
OutputArray& out,
|
||||
const void *src_base,
|
||||
const void *dest_base) const
|
||||
const void *src_base) const
|
||||
{
|
||||
return subset_offset_array_t<OutputArray> (subset_context, out, src_base, dest_base);
|
||||
return subset_offset_array_t<OutputArray> (subset_context, out, src_base);
|
||||
}
|
||||
|
||||
/* Variant with one extra argument passed to serialize_subset */
|
||||
@ -235,10 +230,9 @@ struct
|
||||
(hb_subset_context_t *subset_context,
|
||||
OutputArray& out,
|
||||
const void *src_base,
|
||||
const void *dest_base,
|
||||
Arg &&arg) const
|
||||
{
|
||||
return subset_offset_array_arg_t<OutputArray, Arg> (subset_context, out, src_base, dest_base, arg);
|
||||
return subset_offset_array_arg_t<OutputArray, Arg> (subset_context, out, src_base, arg);
|
||||
}
|
||||
}
|
||||
HB_FUNCOBJ (subset_offset_array);
|
||||
@ -249,9 +243,8 @@ struct subset_record_array_t
|
||||
subset_record_array_t
|
||||
(hb_subset_layout_context_t *c,
|
||||
OutputArray* out,
|
||||
const void *src_base,
|
||||
const void *dest_base)
|
||||
: _subset_layout_context(c), _out (out), _src_base (src_base), _dest_base (dest_base) {}
|
||||
const void *src_base)
|
||||
: _subset_layout_context(c), _out (out), _src_base (src_base) {}
|
||||
|
||||
template <typename T>
|
||||
void
|
||||
@ -259,7 +252,7 @@ struct subset_record_array_t
|
||||
(T&& record)
|
||||
{
|
||||
auto snap = _subset_layout_context->subset_context->serializer->snapshot ();
|
||||
bool ret = record.subset (_subset_layout_context, _src_base, _dest_base);
|
||||
bool ret = record.subset (_subset_layout_context, _src_base);
|
||||
if (!ret) _subset_layout_context->subset_context->serializer->revert (snap);
|
||||
else _out->len++;
|
||||
}
|
||||
@ -268,7 +261,6 @@ struct subset_record_array_t
|
||||
hb_subset_layout_context_t *_subset_layout_context;
|
||||
OutputArray *_out;
|
||||
const void *_src_base;
|
||||
const void *_dest_base;
|
||||
};
|
||||
|
||||
/*
|
||||
@ -282,10 +274,9 @@ struct
|
||||
operator ()
|
||||
(hb_subset_layout_context_t *c,
|
||||
OutputArray* out,
|
||||
const void *src_base,
|
||||
const void *dest_base) const
|
||||
const void *src_base) const
|
||||
{
|
||||
return subset_record_array_t<OutputArray> (c, out, src_base, dest_base);
|
||||
return subset_record_array_t<OutputArray> (c, out, src_base);
|
||||
}
|
||||
}
|
||||
HB_FUNCOBJ (subset_record_array);
|
||||
@ -312,13 +303,12 @@ struct Record
|
||||
int cmp (hb_tag_t a) const { return tag.cmp (a); }
|
||||
|
||||
bool subset (hb_subset_layout_context_t *c,
|
||||
const void *src_base,
|
||||
const void *dst_base) const
|
||||
const void *src_base) const
|
||||
{
|
||||
TRACE_SUBSET (this);
|
||||
auto *out = c->subset_context->serializer->embed (this);
|
||||
if (unlikely (!out)) return_trace (false);
|
||||
bool ret = out->offset.serialize_subset (c->subset_context, offset, src_base, dst_base, c, &tag);
|
||||
bool ret = out->offset.serialize_subset (c->subset_context, offset, src_base, c, &tag);
|
||||
return_trace (ret);
|
||||
}
|
||||
|
||||
@ -378,7 +368,7 @@ struct RecordListOf : RecordArrayOf<Type>
|
||||
if (unlikely (!c->serializer->extend_min (out))) return_trace (false);
|
||||
|
||||
+ this->iter ()
|
||||
| hb_apply (subset_record_array (l, out, this, out))
|
||||
| hb_apply (subset_record_array (l, out, this))
|
||||
;
|
||||
return_trace (true);
|
||||
}
|
||||
@ -405,7 +395,7 @@ struct RecordListOfFeature : RecordListOf<Feature>
|
||||
+ hb_zip (*this, hb_range (count))
|
||||
| hb_filter (l->feature_index_map, hb_second)
|
||||
| hb_map (hb_first)
|
||||
| hb_apply (subset_record_array (l, out, this, out))
|
||||
| hb_apply (subset_record_array (l, out, this))
|
||||
;
|
||||
return_trace (true);
|
||||
}
|
||||
@ -605,7 +595,7 @@ struct Script
|
||||
}
|
||||
else
|
||||
{
|
||||
c->serializer->add_link (out->defaultLangSys, c->serializer->pop_pack (), out);
|
||||
c->serializer->add_link (out->defaultLangSys, c->serializer->pop_pack ());
|
||||
defaultLang = true;
|
||||
}
|
||||
}
|
||||
@ -618,7 +608,7 @@ struct Script
|
||||
const LangSys& l = this+record.offset;
|
||||
return !(l == d);
|
||||
})
|
||||
| hb_apply (subset_record_array (l, &(out->langSys), this, out))
|
||||
| hb_apply (subset_record_array (l, &(out->langSys), this))
|
||||
;
|
||||
|
||||
return_trace (bool (out->langSys.len) || defaultLang || l->table_tag == HB_OT_TAG_GSUB);
|
||||
@ -1086,7 +1076,7 @@ struct Lookup
|
||||
unsigned int lookup_type = get_type ();
|
||||
+ hb_iter (get_subtables <TSubTable> ())
|
||||
| hb_filter ([this, glyphset, lookup_type] (const OffsetTo<TSubTable> &_) { return (this+_).intersects (glyphset, lookup_type); })
|
||||
| hb_apply (subset_offset_array (c, out->get_subtables<TSubTable> (), this, out, lookup_type))
|
||||
| hb_apply (subset_offset_array (c, out->get_subtables<TSubTable> (), this, lookup_type))
|
||||
;
|
||||
|
||||
return_trace (true);
|
||||
@ -1158,7 +1148,7 @@ struct LookupOffsetList : OffsetListOf<TLookup>
|
||||
+ hb_zip (*this, hb_range (count))
|
||||
| hb_filter (l->lookup_index_map, hb_second)
|
||||
| hb_map (hb_first)
|
||||
| hb_apply (subset_offset_array (c, *out, this, out))
|
||||
| hb_apply (subset_offset_array (c, *out, this))
|
||||
;
|
||||
return_trace (true);
|
||||
}
|
||||
@ -2573,7 +2563,7 @@ struct ConditionSet
|
||||
if (unlikely (!out || !c->serializer->extend_min (out))) return_trace (false);
|
||||
|
||||
+ conditions.iter ()
|
||||
| hb_apply (subset_offset_array (c, out->conditions, this, out))
|
||||
| hb_apply (subset_offset_array (c, out->conditions, this))
|
||||
;
|
||||
return_trace (true);
|
||||
}
|
||||
@ -2608,15 +2598,14 @@ struct FeatureTableSubstitutionRecord
|
||||
}
|
||||
|
||||
bool subset (hb_subset_layout_context_t *c,
|
||||
const void *src_base,
|
||||
const void *dst_base) const
|
||||
const void *src_base) const
|
||||
{
|
||||
TRACE_SUBSET (this);
|
||||
auto *out = c->subset_context->serializer->embed (this);
|
||||
if (unlikely (!out)) return_trace (false);
|
||||
|
||||
out->featureIndex = c->feature_index_map->get (featureIndex);
|
||||
bool ret = out->feature.serialize_subset (c->subset_context, feature, src_base, dst_base, c);
|
||||
bool ret = out->feature.serialize_subset (c->subset_context, feature, src_base, c);
|
||||
return_trace (ret);
|
||||
}
|
||||
|
||||
@ -2675,7 +2664,7 @@ struct FeatureTableSubstitution
|
||||
out->version.minor = version.minor;
|
||||
|
||||
+ substitutions.iter ()
|
||||
| hb_apply (subset_record_array (l, &(out->substitutions), this, out))
|
||||
| hb_apply (subset_record_array (l, &(out->substitutions), this))
|
||||
;
|
||||
return_trace (bool (out->substitutions));
|
||||
}
|
||||
@ -2715,16 +2704,15 @@ struct FeatureVariationRecord
|
||||
}
|
||||
|
||||
bool subset (hb_subset_layout_context_t *c,
|
||||
const void *src_base,
|
||||
const void *dst_base) const
|
||||
const void *src_base) const
|
||||
{
|
||||
TRACE_SUBSET (this);
|
||||
auto *out = c->subset_context->serializer->embed (this);
|
||||
if (unlikely (!out)) return_trace (false);
|
||||
|
||||
out->conditions.serialize_subset (c->subset_context, conditions, src_base, dst_base);
|
||||
out->conditions.serialize_subset (c->subset_context, conditions, src_base);
|
||||
|
||||
bool ret = out->substitutions.serialize_subset (c->subset_context, substitutions, src_base, dst_base, c);
|
||||
bool ret = out->substitutions.serialize_subset (c->subset_context, substitutions, src_base, c);
|
||||
return_trace (ret);
|
||||
}
|
||||
|
||||
@ -2803,7 +2791,7 @@ struct FeatureVariations
|
||||
out->version.minor = version.minor;
|
||||
|
||||
+ varRecords.iter ()
|
||||
| hb_apply (subset_record_array (l, &(out->varRecords), this, out))
|
||||
| hb_apply (subset_record_array (l, &(out->varRecords), this))
|
||||
;
|
||||
return_trace (bool (out->varRecords));
|
||||
}
|
||||
|
@ -173,7 +173,7 @@ struct CaretValueFormat3
|
||||
auto *out = c->serializer->embed (this);
|
||||
if (unlikely (!out)) return_trace (false);
|
||||
|
||||
return_trace (out->deviceTable.serialize_copy (c->serializer, deviceTable, this, out));
|
||||
return_trace (out->deviceTable.serialize_copy (c->serializer, deviceTable, this));
|
||||
}
|
||||
|
||||
bool sanitize (hb_sanitize_context_t *c) const
|
||||
@ -272,7 +272,7 @@ struct LigGlyph
|
||||
if (unlikely (!c->serializer->extend_min (out))) return_trace (false);
|
||||
|
||||
+ hb_iter (carets)
|
||||
| hb_apply (subset_offset_array (c, out->carets, this, out))
|
||||
| hb_apply (subset_offset_array (c, out->carets, this))
|
||||
;
|
||||
|
||||
return_trace (bool (out->carets));
|
||||
@ -326,7 +326,7 @@ struct LigCaretList
|
||||
hb_sorted_vector_t<hb_codepoint_t> new_coverage;
|
||||
+ hb_zip (this+coverage, ligGlyph)
|
||||
| hb_filter (glyphset, hb_first)
|
||||
| hb_filter (subset_offset_array (c, out->ligGlyph, this, out), hb_second)
|
||||
| hb_filter (subset_offset_array (c, out->ligGlyph, this), hb_second)
|
||||
| hb_map (hb_first)
|
||||
| hb_map (glyph_map)
|
||||
| hb_sink (new_coverage)
|
||||
@ -381,7 +381,7 @@ struct MarkGlyphSetsFormat1
|
||||
//See issue: https://github.com/khaledhosny/ots/issues/172
|
||||
c->serializer->push ();
|
||||
c->dispatch (this+offset);
|
||||
c->serializer->add_link (*o, c->serializer->pop_pack (), out);
|
||||
c->serializer->add_link (*o, c->serializer->pop_pack ());
|
||||
}
|
||||
|
||||
return_trace (ret && out->coverage.len);
|
||||
@ -550,20 +550,20 @@ struct GDEF
|
||||
auto *out = c->serializer->embed (*this);
|
||||
if (unlikely (!out)) return_trace (false);
|
||||
|
||||
out->glyphClassDef.serialize_subset (c, glyphClassDef, this, out);
|
||||
out->attachList = 0;//TODO(subset) serialize_subset (c, attachList, this, out);
|
||||
out->ligCaretList.serialize_subset (c, ligCaretList, this, out);
|
||||
out->markAttachClassDef.serialize_subset (c, markAttachClassDef, this, out);
|
||||
out->glyphClassDef.serialize_subset (c, glyphClassDef, this);
|
||||
out->attachList = 0;//TODO(subset) serialize_subset (c, attachList, this);
|
||||
out->ligCaretList.serialize_subset (c, ligCaretList, this);
|
||||
out->markAttachClassDef.serialize_subset (c, markAttachClassDef, this);
|
||||
|
||||
if (version.to_int () >= 0x00010002u)
|
||||
{
|
||||
if (!out->markGlyphSetsDef.serialize_subset (c, markGlyphSetsDef, this, out) &&
|
||||
if (!out->markGlyphSetsDef.serialize_subset (c, markGlyphSetsDef, this) &&
|
||||
version.to_int () == 0x00010002u)
|
||||
out->version.minor = 0;
|
||||
}
|
||||
|
||||
if (version.to_int () >= 0x00010003u)
|
||||
out->varStore = 0;// TODO(subset) serialize_subset (c, varStore, this, out);
|
||||
out->varStore = 0;// TODO(subset) serialize_subset (c, varStore, this);
|
||||
|
||||
return_trace (true);
|
||||
}
|
||||
|
@ -160,7 +160,7 @@ struct ValueFormat : HBUINT16
|
||||
return ret;
|
||||
}
|
||||
|
||||
void serialize_copy (hb_serialize_context_t *c, const void *src_base, const void *dst_base, const Value *values) const
|
||||
void serialize_copy (hb_serialize_context_t *c, const void *src_base, const Value *values) const
|
||||
{
|
||||
unsigned int format = *this;
|
||||
if (!format) return;
|
||||
@ -170,10 +170,10 @@ struct ValueFormat : HBUINT16
|
||||
if (format & xAdvance) c->copy (*values++);
|
||||
if (format & yAdvance) c->copy (*values++);
|
||||
|
||||
if (format & xPlaDevice) copy_device (c, src_base, dst_base, values++);
|
||||
if (format & yPlaDevice) copy_device (c, src_base, dst_base, values++);
|
||||
if (format & xAdvDevice) copy_device (c, src_base, dst_base, values++);
|
||||
if (format & yAdvDevice) copy_device (c, src_base, dst_base, values++);
|
||||
if (format & xPlaDevice) copy_device (c, src_base, values++);
|
||||
if (format & yPlaDevice) copy_device (c, src_base, values++);
|
||||
if (format & xAdvDevice) copy_device (c, src_base, values++);
|
||||
if (format & yAdvDevice) copy_device (c, src_base, values++);
|
||||
}
|
||||
|
||||
private:
|
||||
@ -194,7 +194,7 @@ struct ValueFormat : HBUINT16
|
||||
return true;
|
||||
}
|
||||
|
||||
bool copy_device (hb_serialize_context_t *c, const void *src_base, const void *dst_base, const Value *src_value) const
|
||||
bool copy_device (hb_serialize_context_t *c, const void *src_base, const Value *src_value) const
|
||||
{
|
||||
Value *dst_value = c->copy (*src_value);
|
||||
|
||||
@ -205,7 +205,7 @@ struct ValueFormat : HBUINT16
|
||||
c->push ();
|
||||
if ((src_base + get_device (src_value)).copy (c))
|
||||
{
|
||||
c->add_link (*dst_value, c->pop_pack (), dst_base);
|
||||
c->add_link (*dst_value, c->pop_pack ());
|
||||
return true;
|
||||
}
|
||||
else
|
||||
@ -389,8 +389,8 @@ struct AnchorFormat3
|
||||
auto *out = c->embed<AnchorFormat3> (this);
|
||||
if (unlikely (!out)) return_trace (nullptr);
|
||||
|
||||
out->xDeviceTable.serialize_copy (c, xDeviceTable, this, out);
|
||||
out->yDeviceTable.serialize_copy (c, yDeviceTable, this, out);
|
||||
out->xDeviceTable.serialize_copy (c, xDeviceTable, this);
|
||||
out->yDeviceTable.serialize_copy (c, yDeviceTable, this);
|
||||
return_trace (out);
|
||||
}
|
||||
|
||||
@ -485,7 +485,7 @@ struct AnchorMatrix
|
||||
for (const unsigned i : index_iter)
|
||||
{
|
||||
auto *offset = c->embed (offset_matrix->matrixZ[i]);
|
||||
offset->serialize_copy (c, offset_matrix->matrixZ[i], offset_matrix, this);
|
||||
offset->serialize_copy (c, offset_matrix->matrixZ[i], offset_matrix, c->to_bias (this));
|
||||
}
|
||||
|
||||
return_trace (true);
|
||||
@ -525,7 +525,7 @@ struct MarkRecord
|
||||
|
||||
MarkRecord *copy (hb_serialize_context_t *c,
|
||||
const void *src_base,
|
||||
const void *dst_base,
|
||||
unsigned dst_bias,
|
||||
const hb_map_t *klass_mapping) const
|
||||
{
|
||||
TRACE_SERIALIZE (this);
|
||||
@ -533,7 +533,7 @@ struct MarkRecord
|
||||
if (unlikely (!out)) return_trace (nullptr);
|
||||
|
||||
out->klass = klass_mapping->get (klass);
|
||||
out->markAnchor.serialize_copy (c, markAnchor, src_base, dst_base);
|
||||
out->markAnchor.serialize_copy (c, markAnchor, src_base, dst_bias);
|
||||
return_trace (out);
|
||||
}
|
||||
|
||||
@ -592,7 +592,7 @@ struct MarkArray : ArrayOf<MarkRecord> /* Array of MarkRecords--in Coverage orde
|
||||
TRACE_SERIALIZE (this);
|
||||
if (unlikely (!c->extend_min (*this))) return_trace (false);
|
||||
if (unlikely (!c->check_assign (len, it.len ()))) return_trace (false);
|
||||
c->copy_all (it, src_base, this, klass_mapping);
|
||||
c->copy_all (it, src_base, c->to_bias (this), klass_mapping);
|
||||
return_trace (true);
|
||||
}
|
||||
|
||||
@ -645,7 +645,7 @@ struct SinglePosFormat1
|
||||
+ it
|
||||
| hb_map (hb_second)
|
||||
| hb_apply ([&] (hb_array_t<const Value> _)
|
||||
{ valFormat.serialize_copy (c, src, out, &_); })
|
||||
{ valFormat.serialize_copy (c, src, &_); })
|
||||
;
|
||||
|
||||
auto glyphs =
|
||||
@ -740,7 +740,7 @@ struct SinglePosFormat2
|
||||
+ it
|
||||
| hb_map (hb_second)
|
||||
| hb_apply ([&] (hb_array_t<const Value> _)
|
||||
{ valFormat.serialize_copy (c, src, out, &_); })
|
||||
{ valFormat.serialize_copy (c, src, &_); })
|
||||
;
|
||||
|
||||
auto glyphs =
|
||||
@ -876,7 +876,6 @@ struct PairValueRecord
|
||||
struct serialize_closure_t
|
||||
{
|
||||
const void *src_base;
|
||||
void *dst_base;
|
||||
const ValueFormat *valueFormats;
|
||||
unsigned len1; /* valueFormats[0].get_len() */
|
||||
const hb_map_t *glyph_map;
|
||||
@ -891,8 +890,8 @@ struct PairValueRecord
|
||||
|
||||
out->secondGlyph = (*closure->glyph_map)[secondGlyph];
|
||||
|
||||
closure->valueFormats[0].serialize_copy (c, closure->src_base, closure->dst_base, &values[0]);
|
||||
closure->valueFormats[1].serialize_copy (c, closure->src_base, closure->dst_base, &values[closure->len1]);
|
||||
closure->valueFormats[0].serialize_copy (c, closure->src_base, &values[0]);
|
||||
closure->valueFormats[1].serialize_copy (c, closure->src_base, &values[closure->len1]);
|
||||
|
||||
return_trace (true);
|
||||
}
|
||||
@ -988,7 +987,6 @@ struct PairSet
|
||||
PairValueRecord::serialize_closure_t closure =
|
||||
{
|
||||
this,
|
||||
out,
|
||||
valueFormats,
|
||||
len1,
|
||||
&glyph_map
|
||||
@ -1101,7 +1099,7 @@ struct PairPosFormat1
|
||||
auto *o = out->pairSet.serialize_append (c->serializer);
|
||||
if (unlikely (!o)) return false;
|
||||
auto snap = c->serializer->snapshot ();
|
||||
bool ret = o->serialize_subset (c, _, this, out, valueFormat);
|
||||
bool ret = o->serialize_subset (c, _, this, valueFormat);
|
||||
if (!ret)
|
||||
{
|
||||
out->pairSet.pop ();
|
||||
@ -1217,11 +1215,11 @@ struct PairPosFormat2
|
||||
out->valueFormat2 = valueFormat2;
|
||||
|
||||
hb_map_t klass1_map;
|
||||
out->classDef1.serialize_subset (c, classDef1, this, out, &klass1_map);
|
||||
out->classDef1.serialize_subset (c, classDef1, this, &klass1_map);
|
||||
out->class1Count = klass1_map.get_population ();
|
||||
|
||||
hb_map_t klass2_map;
|
||||
out->classDef2.serialize_subset (c, classDef2, this, out, &klass2_map);
|
||||
out->classDef2.serialize_subset (c, classDef2, this, &klass2_map);
|
||||
out->class2Count = klass2_map.get_population ();
|
||||
|
||||
unsigned len1 = valueFormat1.get_len ();
|
||||
@ -1236,8 +1234,8 @@ struct PairPosFormat2
|
||||
| hb_apply ([&] (const unsigned class2_idx)
|
||||
{
|
||||
unsigned idx = (class1_idx * (unsigned) class2Count + class2_idx) * (len1 + len2);
|
||||
valueFormat1.serialize_copy (c->serializer, this, out, &values[idx]);
|
||||
valueFormat2.serialize_copy (c->serializer, this, out, &values[idx + len1]);
|
||||
valueFormat1.serialize_copy (c->serializer, this, &values[idx]);
|
||||
valueFormat2.serialize_copy (c->serializer, this, &values[idx + len1]);
|
||||
})
|
||||
;
|
||||
})
|
||||
@ -1340,15 +1338,14 @@ struct EntryExitRecord
|
||||
}
|
||||
|
||||
EntryExitRecord* copy (hb_serialize_context_t *c,
|
||||
const void *src_base,
|
||||
const void *dst_base) const
|
||||
const void *src_base) const
|
||||
{
|
||||
TRACE_SERIALIZE (this);
|
||||
auto *out = c->embed (this);
|
||||
if (unlikely (!out)) return_trace (nullptr);
|
||||
|
||||
out->entryAnchor.serialize_copy (c, entryAnchor, src_base, dst_base);
|
||||
out->exitAnchor.serialize_copy (c, exitAnchor, src_base, dst_base);
|
||||
out->entryAnchor.serialize_copy (c, entryAnchor, src_base);
|
||||
out->exitAnchor.serialize_copy (c, exitAnchor, src_base);
|
||||
return_trace (out);
|
||||
}
|
||||
|
||||
@ -1493,7 +1490,7 @@ struct CursivePosFormat1
|
||||
|
||||
for (const EntryExitRecord& entry_record : + it
|
||||
| hb_map (hb_second))
|
||||
c->copy (entry_record, src_base, this);
|
||||
c->copy (entry_record, src_base);
|
||||
|
||||
auto glyphs =
|
||||
+ it
|
||||
|
@ -457,7 +457,7 @@ struct MultipleSubstFormat1
|
||||
hb_sorted_vector_t<hb_codepoint_t> new_coverage;
|
||||
+ hb_zip (this+coverage, sequence)
|
||||
| hb_filter (glyphset, hb_first)
|
||||
| hb_filter (subset_offset_array (c, out->sequence, this, out), hb_second)
|
||||
| hb_filter (subset_offset_array (c, out->sequence, this), hb_second)
|
||||
| hb_map (hb_first)
|
||||
| hb_map (glyph_map)
|
||||
| hb_sink (new_coverage)
|
||||
@ -670,7 +670,7 @@ struct AlternateSubstFormat1
|
||||
hb_sorted_vector_t<hb_codepoint_t> new_coverage;
|
||||
+ hb_zip (this+coverage, alternateSet)
|
||||
| hb_filter (glyphset, hb_first)
|
||||
| hb_filter (subset_offset_array (c, out->alternateSet, this, out), hb_second)
|
||||
| hb_filter (subset_offset_array (c, out->alternateSet, this), hb_second)
|
||||
| hb_map (hb_first)
|
||||
| hb_map (glyph_map)
|
||||
| hb_sink (new_coverage)
|
||||
@ -930,7 +930,7 @@ struct LigatureSet
|
||||
if (unlikely (!c->serializer->extend_min (out))) return_trace (false);
|
||||
|
||||
+ hb_iter (ligature)
|
||||
| hb_filter (subset_offset_array (c, out->ligature, this, out))
|
||||
| hb_filter (subset_offset_array (c, out->ligature, this))
|
||||
| hb_drain
|
||||
;
|
||||
return_trace (bool (out->ligature));
|
||||
@ -1046,7 +1046,7 @@ struct LigatureSubstFormat1
|
||||
hb_sorted_vector_t<hb_codepoint_t> new_coverage;
|
||||
+ hb_zip (this+coverage, ligatureSet)
|
||||
| hb_filter (glyphset, hb_first)
|
||||
| hb_filter (subset_offset_array (c, out->ligatureSet, this, out), hb_second)
|
||||
| hb_filter (subset_offset_array (c, out->ligatureSet, this), hb_second)
|
||||
| hb_map (hb_first)
|
||||
| hb_map (glyph_map)
|
||||
| hb_sink (new_coverage)
|
||||
|
@ -2304,7 +2304,7 @@ struct ChainRuleSet
|
||||
if (unlikely (!o)) continue;
|
||||
|
||||
auto o_snap = c->serializer->snapshot ();
|
||||
if (!o->serialize_subset (c, _, this, out,
|
||||
if (!o->serialize_subset (c, _, this,
|
||||
backtrack_klass_map,
|
||||
input_klass_map,
|
||||
lookahead_klass_map))
|
||||
@ -2430,7 +2430,7 @@ struct ChainContextFormat1
|
||||
hb_sorted_vector_t<hb_codepoint_t> new_coverage;
|
||||
+ hb_zip (this+coverage, ruleSet)
|
||||
| hb_filter (glyphset, hb_first)
|
||||
| hb_filter (subset_offset_array (c, out->ruleSet, this, out), hb_second)
|
||||
| hb_filter (subset_offset_array (c, out->ruleSet, this), hb_second)
|
||||
| hb_map (hb_first)
|
||||
| hb_map (glyph_map)
|
||||
| hb_sink (new_coverage)
|
||||
@ -2587,17 +2587,17 @@ struct ChainContextFormat2
|
||||
auto *out = c->serializer->start_embed (*this);
|
||||
if (unlikely (!c->serializer->extend_min (out))) return_trace (false);
|
||||
out->format = format;
|
||||
out->coverage.serialize_subset (c, coverage, this, out);
|
||||
out->coverage.serialize_subset (c, coverage, this);
|
||||
|
||||
hb_map_t backtrack_klass_map;
|
||||
out->backtrackClassDef.serialize_subset (c, backtrackClassDef, this, out, &backtrack_klass_map);
|
||||
out->backtrackClassDef.serialize_subset (c, backtrackClassDef, this, &backtrack_klass_map);
|
||||
|
||||
// subset inputClassDef based on glyphs survived in Coverage subsetting
|
||||
hb_map_t input_klass_map;
|
||||
out->inputClassDef.serialize_subset (c, inputClassDef, this, out, &input_klass_map);
|
||||
out->inputClassDef.serialize_subset (c, inputClassDef, this, &input_klass_map);
|
||||
|
||||
hb_map_t lookahead_klass_map;
|
||||
out->lookaheadClassDef.serialize_subset (c, lookaheadClassDef, this, out, &lookahead_klass_map);
|
||||
out->lookaheadClassDef.serialize_subset (c, lookaheadClassDef, this, &lookahead_klass_map);
|
||||
|
||||
hb_vector_t<unsigned> rulesets;
|
||||
bool ret = true;
|
||||
@ -2611,7 +2611,7 @@ struct ChainContextFormat2
|
||||
ret = false;
|
||||
break;
|
||||
}
|
||||
if (!o->serialize_subset (c, _, this, out,
|
||||
if (!o->serialize_subset (c, _, this,
|
||||
&backtrack_klass_map,
|
||||
&input_klass_map,
|
||||
&lookahead_klass_map))
|
||||
@ -2785,8 +2785,7 @@ struct ChainContextFormat3
|
||||
hb_requires (hb_is_iterator (Iterator))>
|
||||
bool serialize_coverage_offsets (hb_subset_context_t *c,
|
||||
Iterator it,
|
||||
const void* src_base,
|
||||
const void* dst_base) const
|
||||
const void* src_base) const
|
||||
{
|
||||
TRACE_SERIALIZE (this);
|
||||
auto *out = c->serializer->start_embed<OffsetArrayOf<Coverage>> ();
|
||||
@ -2794,7 +2793,7 @@ struct ChainContextFormat3
|
||||
if (unlikely (!c->serializer->allocate_size<HBUINT16> (HBUINT16::static_size))) return_trace (false);
|
||||
|
||||
+ it
|
||||
| hb_apply (subset_offset_array (c, *out, src_base, dst_base))
|
||||
| hb_apply (subset_offset_array (c, *out, src_base))
|
||||
;
|
||||
|
||||
return_trace (out->len);
|
||||
@ -2808,15 +2807,15 @@ struct ChainContextFormat3
|
||||
if (unlikely (!out)) return_trace (false);
|
||||
if (unlikely (!c->serializer->embed (this->format))) return_trace (false);
|
||||
|
||||
if (!serialize_coverage_offsets (c, backtrack.iter (), this, out))
|
||||
if (!serialize_coverage_offsets (c, backtrack.iter (), this))
|
||||
return_trace (false);
|
||||
|
||||
const OffsetArrayOf<Coverage> &input = StructAfter<OffsetArrayOf<Coverage>> (backtrack);
|
||||
if (!serialize_coverage_offsets (c, input.iter (), this, out))
|
||||
if (!serialize_coverage_offsets (c, input.iter (), this))
|
||||
return_trace (false);
|
||||
|
||||
const OffsetArrayOf<Coverage> &lookahead = StructAfter<OffsetArrayOf<Coverage>> (input);
|
||||
if (!serialize_coverage_offsets (c, lookahead.iter (), this, out))
|
||||
if (!serialize_coverage_offsets (c, lookahead.iter (), this))
|
||||
return_trace (false);
|
||||
|
||||
const ArrayOf<LookupRecord> &lookup = StructAfter<ArrayOf<LookupRecord>> (lookahead);
|
||||
@ -3070,26 +3069,23 @@ struct GSUBGPOS
|
||||
.serialize_subset (c->subset_context,
|
||||
reinterpret_cast<const OffsetTo<TLookupList> &> (lookupList),
|
||||
this,
|
||||
out,
|
||||
c);
|
||||
|
||||
reinterpret_cast<OffsetTo<RecordListOfFeature> &> (out->featureList)
|
||||
.serialize_subset (c->subset_context,
|
||||
reinterpret_cast<const OffsetTo<RecordListOfFeature> &> (featureList),
|
||||
this,
|
||||
out,
|
||||
c);
|
||||
|
||||
out->scriptList.serialize_subset (c->subset_context,
|
||||
scriptList,
|
||||
this,
|
||||
out,
|
||||
c);
|
||||
|
||||
#ifndef HB_NO_VAR
|
||||
if (version.to_int () >= 0x00010001u)
|
||||
{
|
||||
bool ret = out->featureVars.serialize_subset (c->subset_context, featureVars, this, out, c);
|
||||
bool ret = out->featureVars.serialize_subset (c->subset_context, featureVars, this, c);
|
||||
if (!ret)
|
||||
{
|
||||
out->version.major = 1;
|
||||
|
@ -103,7 +103,7 @@ struct NameRecord
|
||||
TRACE_SERIALIZE (this);
|
||||
auto *out = c->embed (this);
|
||||
if (unlikely (!out)) return_trace (nullptr);
|
||||
out->offset.serialize_copy (c, offset, src_base, nullptr, hb_serialize_context_t::Tail, length);
|
||||
out->offset.serialize_copy (c, offset, src_base, 0, hb_serialize_context_t::Tail, length);
|
||||
return_trace (out);
|
||||
}
|
||||
|
||||
|
@ -278,7 +278,7 @@ struct hb_serialize_context_t
|
||||
|
||||
template <typename T>
|
||||
void add_link (T &ofs, objidx_t objidx,
|
||||
whence_t whence,
|
||||
whence_t whence = Head,
|
||||
unsigned bias = 0)
|
||||
{
|
||||
static_assert (sizeof (T) == 2 || sizeof (T) == 4, "");
|
||||
@ -299,11 +299,13 @@ struct hb_serialize_context_t
|
||||
link.objidx = objidx;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void add_link (T &ofs, objidx_t objidx,
|
||||
const void *base = nullptr,
|
||||
whence_t whence = Head)
|
||||
{ add_link (ofs, objidx, whence, to_bias (base)); }
|
||||
unsigned to_bias (const void *base) const
|
||||
{
|
||||
if (!base) return 0;
|
||||
assert (current);
|
||||
assert (current->head <= (const char *) base);
|
||||
return (const char *) base - current->head;
|
||||
}
|
||||
|
||||
void resolve_links ()
|
||||
{
|
||||
@ -489,14 +491,6 @@ struct hb_serialize_context_t
|
||||
check_assign (off, offset);
|
||||
}
|
||||
|
||||
unsigned to_bias (const void *base) const
|
||||
{
|
||||
if (!base) return 0;
|
||||
assert (current);
|
||||
assert (current->head <= (const char *) base);
|
||||
return (const char *) base - current->head;
|
||||
}
|
||||
|
||||
public: /* TODO Make private. */
|
||||
char *start, *head, *tail, *end;
|
||||
unsigned int debug_depth;
|
||||
|
Loading…
Reference in New Issue
Block a user