[subset] GDEF AttachList subsetting support

This commit is contained in:
Qunxin Liu 2020-02-18 10:02:19 -08:00 committed by Garret Rieger
parent 368ca30641
commit 3c5bdd9bb8
17 changed files with 52 additions and 4 deletions

View File

@ -41,8 +41,18 @@ namespace OT {
* Attachment List Table
*/
typedef ArrayOf<HBUINT16> AttachPoint; /* Array of contour point indices--in
* increasing numerical order */
/* Array of contour point indices--in increasing numerical order */
struct AttachPoint : ArrayOf<HBUINT16>
{
bool subset (hb_subset_context_t *c) const
{
TRACE_SUBSET (this);
auto *out = c->serializer->start_embed (*this);
if (unlikely (!out)) return_trace (false);
return_trace (out->serialize (c->serializer, + iter ()));
}
};
struct AttachList
{
@ -72,6 +82,28 @@ struct AttachList
return points.len;
}
bool subset (hb_subset_context_t *c) const
{
TRACE_SUBSET (this);
const hb_set_t &glyphset = *c->plan->glyphset ();
const hb_map_t &glyph_map = *c->plan->glyph_map;
auto *out = c->serializer->start_embed (*this);
if (unlikely (!c->serializer->extend_min (out))) return_trace (false);
hb_sorted_vector_t<hb_codepoint_t> new_coverage;
+ hb_zip (this+coverage, attachPoint)
| hb_filter (glyphset, hb_first)
| hb_filter (subset_offset_array (c, out->attachPoint, this), hb_second)
| hb_map (hb_first)
| hb_map (glyph_map)
| hb_sink (new_coverage)
;
out->coverage.serialize (c->serializer, out)
.serialize (c->serializer, new_coverage.iter ());
return_trace (bool (new_coverage));
}
bool sanitize (hb_sanitize_context_t *c) const
{
TRACE_SANITIZE (this);
@ -613,7 +645,7 @@ struct GDEF
if (unlikely (!out)) return_trace (false);
bool subset_glyphclassdef = out->glyphClassDef.serialize_subset (c, glyphClassDef, this);
out->attachList = 0;//TODO(subset) serialize_subset (c, attachList, this);
bool subset_attachlist = out->attachList.serialize_subset (c, attachList, this);
bool subset_ligcaretlist = out->ligCaretList.serialize_subset (c, ligCaretList, this);
bool subset_markattachclassdef = out->markAttachClassDef.serialize_subset (c, markAttachClassDef, this);
@ -634,7 +666,8 @@ struct GDEF
out->version.minor = 2;
}
return_trace (subset_glyphclassdef || subset_ligcaretlist || subset_markattachclassdef ||
return_trace (subset_glyphclassdef || subset_attachlist ||
subset_ligcaretlist || subset_markattachclassdef ||
(out->version.to_int () >= 0x00010002u && subset_markglyphsetsdef) ||
(out->version.to_int () >= 0x00010003u && subset_varstore));
}

View File

@ -24,6 +24,7 @@ EXTRA_DIST += \
expected/layout.gdef \
expected/layout.context \
expected/layout.gdef-varstore \
expected/layout.gdef-attachlist \
expected/cmap \
expected/cmap14 \
expected/sbix \

View File

@ -24,6 +24,7 @@ DISABLED_TESTS = \
tests/layout.gdef.tests \
tests/layout.context.tests \
tests/layout.gdef-varstore.tests \
tests/layout.gdef-attachlist.tests \
$(NULL)
XFAIL_TESTS = \

Binary file not shown.

View File

@ -0,0 +1,13 @@
FONTS:
IndicTestJalandhar-Regular.ttf
PROFILES:
default.txt
drop-hints.txt
keep-gdef.txt
SUBSETS:
ਅਆ
ਇਛ
*