[subset] Starting to sketch glyf as iter
This commit is contained in:
parent
df237d2fe7
commit
f9b089b695
|
@ -81,24 +81,52 @@ struct glyf
|
||||||
return_trace (true);
|
return_trace (true);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool subset (hb_subset_plan_t *plan) const
|
template <typename Iterator>
|
||||||
|
bool serialize(hb_serialize_context_t *c,
|
||||||
|
Iterator it)
|
||||||
{
|
{
|
||||||
hb_blob_t *glyf_prime = nullptr;
|
TRACE_SERIALIZE (this);
|
||||||
hb_blob_t *loca_prime = nullptr;
|
|
||||||
|
|
||||||
bool success = true;
|
// TODO actually copy glyph
|
||||||
bool use_short_loca = false;
|
// TODO worry about instructions
|
||||||
if (hb_subset_glyf_and_loca (plan, &use_short_loca, &glyf_prime, &loca_prime)) {
|
// TODO capture dest locations for loca
|
||||||
success = success && plan->add_table (HB_OT_TAG_glyf, glyf_prime);
|
|
||||||
success = success && plan->add_table (HB_OT_TAG_loca, loca_prime);
|
return_trace (true);
|
||||||
success = success && _add_head_and_set_loca_version (plan, use_short_loca);
|
|
||||||
} else {
|
|
||||||
success = false;
|
|
||||||
}
|
}
|
||||||
hb_blob_destroy (loca_prime);
|
|
||||||
hb_blob_destroy (glyf_prime);
|
|
||||||
|
|
||||||
return success;
|
bool subset (hb_subset_context_t *c) const
|
||||||
|
{
|
||||||
|
TRACE_SUBSET (this);
|
||||||
|
|
||||||
|
glyf *glyf_prime = c->serializer->start_embed <glyf> ();
|
||||||
|
if (unlikely (!glyf_prime)) return_trace (false);
|
||||||
|
|
||||||
|
OT::glyf::accelerator_t glyf;
|
||||||
|
glyf.init (c->plan->source);
|
||||||
|
|
||||||
|
// stream new-gids => pair of start/end offsets
|
||||||
|
// can now copy glyph from <prev>=>end
|
||||||
|
// TODO(instructions)
|
||||||
|
auto it =
|
||||||
|
+ hb_iota (c->plan->num_output_glyphs ())
|
||||||
|
| hb_map ([&] (hb_codepoint_t new_gid) {
|
||||||
|
unsigned int start_offset = 0, end_offset = 0;
|
||||||
|
// simple case: empty glyph
|
||||||
|
hb_codepoint_t old_gid;
|
||||||
|
if (!c->plan->old_gid_for_new_gid (new_gid, &old_gid)) return hb_pair (start_offset, end_offset);
|
||||||
|
|
||||||
|
if (unlikely (!(glyf.get_offsets (old_gid, &start_offset, &end_offset) &&
|
||||||
|
glyf.remove_padding (start_offset, &end_offset))))
|
||||||
|
{
|
||||||
|
// TODO signal irreversible error
|
||||||
|
return hb_pair (start_offset, end_offset);
|
||||||
|
}
|
||||||
|
return hb_pair (start_offset, end_offset);
|
||||||
|
});
|
||||||
|
|
||||||
|
glyf_prime->serialize (c->serializer, it);
|
||||||
|
|
||||||
|
return_trace (true);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
|
|
|
@ -68,6 +68,8 @@ struct hb_subset_plan_t
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The set of input glyph ids which will be retained in the subset.
|
* The set of input glyph ids which will be retained in the subset.
|
||||||
|
* Does NOT include ids kept due to retain_gids. You probably want to use
|
||||||
|
* glyph_map/reverse_glyph_map.
|
||||||
*/
|
*/
|
||||||
inline const hb_set_t *
|
inline const hb_set_t *
|
||||||
glyphset () const
|
glyphset () const
|
||||||
|
|
|
@ -156,7 +156,7 @@ _subset_table (hb_subset_plan_t *plan,
|
||||||
bool result = true;
|
bool result = true;
|
||||||
switch (tag) {
|
switch (tag) {
|
||||||
case HB_OT_TAG_glyf:
|
case HB_OT_TAG_glyf:
|
||||||
result = _subset<const OT::glyf> (plan);
|
result = _subset2<const OT::glyf> (plan);
|
||||||
break;
|
break;
|
||||||
case HB_OT_TAG_hdmx:
|
case HB_OT_TAG_hdmx:
|
||||||
result = _subset<const OT::hdmx> (plan);
|
result = _subset<const OT::hdmx> (plan);
|
||||||
|
|
Loading…
Reference in New Issue