[subset] GDEF MarkGlyphSets subsetting support

pull/2199/head
Qunxin Liu 5 years ago committed by Garret Rieger
parent fcd7f33bbb
commit 5ad761b943
  1. 43
      src/hb-ot-layout-gdef-table.hh
  2. 1
      test/subset/data/Makefile.am
  3. 1
      test/subset/data/Makefile.sources
  4. BIN
      test/subset/data/expected/layout.gdef/Roboto-Regular.default.1E00,303.ttf
  5. BIN
      test/subset/data/expected/layout.gdef/Roboto-Regular.default.303.ttf
  6. BIN
      test/subset/data/expected/layout.gdef/Roboto-Regular.default.309,20,30F.ttf
  7. BIN
      test/subset/data/expected/layout.gdef/Roboto-Regular.default.323.ttf
  8. BIN
      test/subset/data/expected/layout.gdef/Roboto-Regular.default.41,42,43.ttf
  9. BIN
      test/subset/data/expected/layout.gdef/Roboto-Regular.drop-hints.1E00,303.ttf
  10. BIN
      test/subset/data/expected/layout.gdef/Roboto-Regular.drop-hints.303.ttf
  11. BIN
      test/subset/data/expected/layout.gdef/Roboto-Regular.drop-hints.309,20,30F.ttf
  12. BIN
      test/subset/data/expected/layout.gdef/Roboto-Regular.drop-hints.323.ttf
  13. BIN
      test/subset/data/expected/layout.gdef/Roboto-Regular.drop-hints.41,42,43.ttf
  14. BIN
      test/subset/data/expected/layout.gdef/Roboto-Regular.keep-gdef.1E00,303.ttf
  15. BIN
      test/subset/data/expected/layout.gdef/Roboto-Regular.keep-gdef.303.ttf
  16. BIN
      test/subset/data/expected/layout.gdef/Roboto-Regular.keep-gdef.309,20,30F.ttf
  17. BIN
      test/subset/data/expected/layout.gdef/Roboto-Regular.keep-gdef.323.ttf
  18. BIN
      test/subset/data/expected/layout.gdef/Roboto-Regular.keep-gdef.41,42,43.ttf
  19. 14
      test/subset/data/tests/layout.gdef.tests

@ -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);

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

@ -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 \

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