[subset] GDEF MarkGlyphSets subsetting support

This commit is contained in:
Qunxin Liu 2020-02-11 13:05:40 -08:00 committed by Garret Rieger
parent fcd7f33bbb
commit 5ad761b943
19 changed files with 58 additions and 1 deletions

View File

@ -288,6 +288,34 @@ struct MarkGlyphSetsFormat1
bool covers (unsigned int set_index, hb_codepoint_t glyph_id) const
{ return (this+coverage[set_index]).get_coverage (glyph_id) != NOT_COVERED; }
bool subset (hb_subset_context_t *c) const
{
TRACE_SUBSET (this);
auto *out = c->serializer->start_embed (*this);
if (unlikely (!c->serializer->extend_min (out))) return_trace (false);
out->format = format;
bool ret = true;
for (const LOffsetTo<Coverage>& offset : coverage.iter ())
{
auto *o = out->coverage.serialize_append (c->serializer);
if (unlikely (!o))
{
ret = false;
break;
}
//not using o->serialize_subset (c, offset, this, out) here because
//OTS doesn't allow null offset.
//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);
}
return_trace (ret && out->coverage.len);
}
bool sanitize (hb_sanitize_context_t *c) const
{
TRACE_SANITIZE (this);
@ -313,6 +341,15 @@ struct MarkGlyphSets
}
}
bool subset (hb_subset_context_t *c) const
{
TRACE_SUBSET (this);
switch (u.format) {
case 1: return_trace (u.format1.subset (c));
default:return_trace (false);
}
}
bool sanitize (hb_sanitize_context_t *c) const
{
TRACE_SANITIZE (this);
@ -448,7 +485,11 @@ struct GDEF
out->markAttachClassDef.serialize_subset (c, markAttachClassDef, this, out);
if (version.to_int () >= 0x00010002u)
out->markGlyphSetsDef = 0;// TODO(subset) serialize_subset (c, markGlyphSetsDef, this, out);
{
if (!out->markGlyphSetsDef.serialize_subset (c, markGlyphSetsDef, this, out) &&
version.to_int () == 0x00010002u)
out->version.minor = 0;
}
if (version.to_int () >= 0x00010003u)
out->varStore = 0;// TODO(subset) serialize_subset (c, varStore, this, out);

View File

@ -20,6 +20,7 @@ EXTRA_DIST += \
expected/layout.gpos6 \
expected/layout.gsub3 \
expected/layout.gsub6 \
expected/layout.gdef \
expected/cmap \
expected/cmap14 \
expected/sbix \

View File

@ -12,6 +12,7 @@ TESTS = \
tests/layout.gpos6.tests \
tests/layout.gsub3.tests \
tests/layout.gsub6.tests \
tests/layout.gdef.tests \
tests/cmap.tests \
tests/cmap14.tests \
tests/sbix.tests \

View File

@ -0,0 +1,14 @@
FONTS:
Roboto-Regular.ttf
PROFILES:
default.txt
drop-hints.txt
keep-gdef.txt
SUBSETS:
Ḁ̃
̣
̃
̉ ̏
ABC