Merge pull request #4452 from googlefonts/fix_test

[subset] bug fixes for GDEF
pull/4455/head
Behdad Esfahbod 1 year ago committed by GitHub
commit fde1c3692a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 50
      src/OT/Layout/GDEF/GDEF.hh
  2. 16
      src/hb-ot-layout-common.hh
  3. 3
      src/hb-subset-plan-member-list.hh
  4. 21
      src/hb-subset-plan.cc
  5. 1
      test/subset/data/Makefile.am
  6. 1
      test/subset/data/Makefile.sources
  7. BIN
      test/subset/data/expected/apply_cvar_delta/Comfortaa-Regular-new.default.retain-all-codepoint.wght=300.ttf
  8. BIN
      test/subset/data/expected/apply_cvar_delta/Comfortaa-Regular-new.default.retain-all-codepoint.wght=700.ttf
  9. BIN
      test/subset/data/expected/apply_cvar_delta/Muli-ABC.default.retain-all-codepoint.wght=300.ttf
  10. BIN
      test/subset/data/expected/apply_cvar_delta/Muli-ABC.default.retain-all-codepoint.wght=700.ttf
  11. BIN
      test/subset/data/expected/basics/Comfortaa-Regular-new.default.61,62,63.ttf
  12. BIN
      test/subset/data/expected/basics/Comfortaa-Regular-new.default.61,63.ttf
  13. BIN
      test/subset/data/expected/basics/Comfortaa-Regular-new.default.61.ttf
  14. BIN
      test/subset/data/expected/basics/Comfortaa-Regular-new.default.62.ttf
  15. BIN
      test/subset/data/expected/basics/Comfortaa-Regular-new.default.63.ttf
  16. BIN
      test/subset/data/expected/basics/Comfortaa-Regular-new.drop-hints-retain-gids.61,62,63.ttf
  17. BIN
      test/subset/data/expected/basics/Comfortaa-Regular-new.drop-hints-retain-gids.61,63.ttf
  18. BIN
      test/subset/data/expected/basics/Comfortaa-Regular-new.drop-hints-retain-gids.61.ttf
  19. BIN
      test/subset/data/expected/basics/Comfortaa-Regular-new.drop-hints-retain-gids.62.ttf
  20. BIN
      test/subset/data/expected/basics/Comfortaa-Regular-new.drop-hints-retain-gids.63.ttf
  21. BIN
      test/subset/data/expected/basics/Comfortaa-Regular-new.drop-hints.61,62,63.ttf
  22. BIN
      test/subset/data/expected/basics/Comfortaa-Regular-new.drop-hints.61,63.ttf
  23. BIN
      test/subset/data/expected/basics/Comfortaa-Regular-new.drop-hints.61.ttf
  24. BIN
      test/subset/data/expected/basics/Comfortaa-Regular-new.drop-hints.62.ttf
  25. BIN
      test/subset/data/expected/basics/Comfortaa-Regular-new.drop-hints.63.ttf
  26. BIN
      test/subset/data/expected/basics/Comfortaa-Regular-new.gids.61,62,63.ttf
  27. BIN
      test/subset/data/expected/basics/Comfortaa-Regular-new.gids.61,63.ttf
  28. BIN
      test/subset/data/expected/basics/Comfortaa-Regular-new.gids.61.ttf
  29. BIN
      test/subset/data/expected/basics/Comfortaa-Regular-new.gids.62.ttf
  30. BIN
      test/subset/data/expected/basics/Comfortaa-Regular-new.gids.63.ttf
  31. BIN
      test/subset/data/expected/basics/Comfortaa-Regular-new.glyph-names.61,62,63.ttf
  32. BIN
      test/subset/data/expected/basics/Comfortaa-Regular-new.glyph-names.61,63.ttf
  33. BIN
      test/subset/data/expected/basics/Comfortaa-Regular-new.glyph-names.61.ttf
  34. BIN
      test/subset/data/expected/basics/Comfortaa-Regular-new.glyph-names.62.ttf
  35. BIN
      test/subset/data/expected/basics/Comfortaa-Regular-new.glyph-names.63.ttf
  36. BIN
      test/subset/data/expected/basics/Comfortaa-Regular-new.keep-all-layout-features.61,62,63.ttf
  37. BIN
      test/subset/data/expected/basics/Comfortaa-Regular-new.keep-all-layout-features.61,63.ttf
  38. BIN
      test/subset/data/expected/basics/Comfortaa-Regular-new.keep-all-layout-features.61.ttf
  39. BIN
      test/subset/data/expected/basics/Comfortaa-Regular-new.keep-all-layout-features.62.ttf
  40. BIN
      test/subset/data/expected/basics/Comfortaa-Regular-new.keep-all-layout-features.63.ttf
  41. BIN
      test/subset/data/expected/basics/Comfortaa-Regular-new.layout-features.61,62,63.ttf
  42. BIN
      test/subset/data/expected/basics/Comfortaa-Regular-new.layout-features.61,63.ttf
  43. BIN
      test/subset/data/expected/basics/Comfortaa-Regular-new.layout-features.61.ttf
  44. BIN
      test/subset/data/expected/basics/Comfortaa-Regular-new.layout-features.62.ttf
  45. BIN
      test/subset/data/expected/basics/Comfortaa-Regular-new.layout-features.63.ttf
  46. BIN
      test/subset/data/expected/basics/Comfortaa-Regular-new.name-ids.61,62,63.ttf
  47. BIN
      test/subset/data/expected/basics/Comfortaa-Regular-new.name-ids.61,63.ttf
  48. BIN
      test/subset/data/expected/basics/Comfortaa-Regular-new.name-ids.61.ttf
  49. BIN
      test/subset/data/expected/basics/Comfortaa-Regular-new.name-ids.62.ttf
  50. BIN
      test/subset/data/expected/basics/Comfortaa-Regular-new.name-ids.63.ttf
  51. BIN
      test/subset/data/expected/basics/Comfortaa-Regular-new.name-languages.61,62,63.ttf
  52. BIN
      test/subset/data/expected/basics/Comfortaa-Regular-new.name-languages.61,63.ttf
  53. BIN
      test/subset/data/expected/basics/Comfortaa-Regular-new.name-languages.61.ttf
  54. BIN
      test/subset/data/expected/basics/Comfortaa-Regular-new.name-languages.62.ttf
  55. BIN
      test/subset/data/expected/basics/Comfortaa-Regular-new.name-languages.63.ttf
  56. BIN
      test/subset/data/expected/basics/Comfortaa-Regular-new.name-legacy.61,62,63.ttf
  57. BIN
      test/subset/data/expected/basics/Comfortaa-Regular-new.name-legacy.61,63.ttf
  58. BIN
      test/subset/data/expected/basics/Comfortaa-Regular-new.name-legacy.61.ttf
  59. BIN
      test/subset/data/expected/basics/Comfortaa-Regular-new.name-legacy.62.ttf
  60. BIN
      test/subset/data/expected/basics/Comfortaa-Regular-new.name-legacy.63.ttf
  61. BIN
      test/subset/data/expected/basics/Comfortaa-Regular-new.no-prune-unicode-ranges.61,62,63.ttf
  62. BIN
      test/subset/data/expected/basics/Comfortaa-Regular-new.no-prune-unicode-ranges.61,63.ttf
  63. BIN
      test/subset/data/expected/basics/Comfortaa-Regular-new.no-prune-unicode-ranges.61.ttf
  64. BIN
      test/subset/data/expected/basics/Comfortaa-Regular-new.no-prune-unicode-ranges.62.ttf
  65. BIN
      test/subset/data/expected/basics/Comfortaa-Regular-new.no-prune-unicode-ranges.63.ttf
  66. BIN
      test/subset/data/expected/basics/Comfortaa-Regular-new.notdef-outline.61,62,63.ttf
  67. BIN
      test/subset/data/expected/basics/Comfortaa-Regular-new.notdef-outline.61,63.ttf
  68. BIN
      test/subset/data/expected/basics/Comfortaa-Regular-new.notdef-outline.61.ttf
  69. BIN
      test/subset/data/expected/basics/Comfortaa-Regular-new.notdef-outline.62.ttf
  70. BIN
      test/subset/data/expected/basics/Comfortaa-Regular-new.notdef-outline.63.ttf
  71. BIN
      test/subset/data/expected/basics/Comfortaa-Regular-new.retain-gids.61,62,63.ttf
  72. BIN
      test/subset/data/expected/basics/Comfortaa-Regular-new.retain-gids.61,63.ttf
  73. BIN
      test/subset/data/expected/basics/Comfortaa-Regular-new.retain-gids.61.ttf
  74. BIN
      test/subset/data/expected/basics/Comfortaa-Regular-new.retain-gids.62.ttf
  75. BIN
      test/subset/data/expected/basics/Comfortaa-Regular-new.retain-gids.63.ttf
  76. BIN
      test/subset/data/expected/basics/Roboto-Regular.abc.default.61,62,63.ttf
  77. BIN
      test/subset/data/expected/basics/Roboto-Regular.abc.default.61,63.ttf
  78. BIN
      test/subset/data/expected/basics/Roboto-Regular.abc.default.61.ttf
  79. BIN
      test/subset/data/expected/basics/Roboto-Regular.abc.default.62.ttf
  80. BIN
      test/subset/data/expected/basics/Roboto-Regular.abc.default.63.ttf
  81. BIN
      test/subset/data/expected/basics/Roboto-Regular.abc.default.retain-all-codepoint.ttf
  82. BIN
      test/subset/data/expected/basics/Roboto-Regular.abc.drop-hints-retain-gids.61,62,63.ttf
  83. BIN
      test/subset/data/expected/basics/Roboto-Regular.abc.drop-hints-retain-gids.61,63.ttf
  84. BIN
      test/subset/data/expected/basics/Roboto-Regular.abc.drop-hints-retain-gids.61.ttf
  85. BIN
      test/subset/data/expected/basics/Roboto-Regular.abc.drop-hints-retain-gids.62.ttf
  86. BIN
      test/subset/data/expected/basics/Roboto-Regular.abc.drop-hints-retain-gids.63.ttf
  87. BIN
      test/subset/data/expected/basics/Roboto-Regular.abc.drop-hints-retain-gids.retain-all-codepoint.ttf
  88. BIN
      test/subset/data/expected/basics/Roboto-Regular.abc.drop-hints.61,62,63.ttf
  89. BIN
      test/subset/data/expected/basics/Roboto-Regular.abc.drop-hints.61,63.ttf
  90. BIN
      test/subset/data/expected/basics/Roboto-Regular.abc.drop-hints.61.ttf
  91. BIN
      test/subset/data/expected/basics/Roboto-Regular.abc.drop-hints.62.ttf
  92. BIN
      test/subset/data/expected/basics/Roboto-Regular.abc.drop-hints.63.ttf
  93. BIN
      test/subset/data/expected/basics/Roboto-Regular.abc.drop-hints.retain-all-codepoint.ttf
  94. BIN
      test/subset/data/expected/basics/Roboto-Regular.abc.gids.61,62,63.ttf
  95. BIN
      test/subset/data/expected/basics/Roboto-Regular.abc.gids.61,63.ttf
  96. BIN
      test/subset/data/expected/basics/Roboto-Regular.abc.gids.61.ttf
  97. BIN
      test/subset/data/expected/basics/Roboto-Regular.abc.gids.62.ttf
  98. BIN
      test/subset/data/expected/basics/Roboto-Regular.abc.gids.63.ttf
  99. BIN
      test/subset/data/expected/basics/Roboto-Regular.abc.gids.retain-all-codepoint.ttf
  100. BIN
      test/subset/data/expected/basics/Roboto-Regular.abc.glyph-names.61,62,63.ttf
  101. Some files were not shown because too many files have changed in this diff Show More

@ -441,6 +441,20 @@ 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; }
void collect_used_mark_sets (const hb_set_t& glyph_set,
hb_set_t& used_mark_sets /* OUT */) const
{
unsigned i = 0;
for (const auto &offset : coverage)
{
const auto &cov = this+offset;
if (cov.intersects (&glyph_set))
used_mark_sets.add (i);
i++;
}
}
template <typename set_t>
void collect_coverage (hb_vector_t<set_t> &sets) const
{
@ -461,6 +475,7 @@ struct MarkGlyphSetsFormat1
bool ret = true;
for (const Offset32To<Coverage>& offset : coverage.iter ())
{
auto snap = c->serializer->snapshot ();
auto *o = out->coverage.serialize_append (c->serializer);
if (unlikely (!o))
{
@ -468,11 +483,17 @@ struct MarkGlyphSetsFormat1
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
//skip empty coverage
c->serializer->push ();
c->dispatch (this+offset);
bool res = false;
if (offset) res = c->dispatch (this+offset);
if (!res)
{
c->serializer->pop_discard ();
c->serializer->revert (snap);
(out->coverage.len)--;
continue;
}
c->serializer->add_link (*o, c->serializer->pop_pack ());
}
@ -513,6 +534,15 @@ struct MarkGlyphSets
}
}
void collect_used_mark_sets (const hb_set_t& glyph_set,
hb_set_t& used_mark_sets /* OUT */) const
{
switch (u.format) {
case 1: u.format1.collect_used_mark_sets (glyph_set, used_mark_sets); return;
default:return;
}
}
bool subset (hb_subset_context_t *c) const
{
TRACE_SUBSET (this);
@ -627,23 +657,29 @@ struct GDEFVersion1_2
bool subset (hb_subset_context_t *c) const
{
TRACE_SUBSET (this);
auto *out = c->serializer->embed (*this);
if (unlikely (!out)) return_trace (false);
auto *out = c->serializer->start_embed (*this);
if (unlikely (!c->serializer->extend_min (out))) return_trace (false);
out->version.major = version.major;
out->version.minor = version.minor;
bool subset_glyphclassdef = out->glyphClassDef.serialize_subset (c, glyphClassDef, this, nullptr, false, true);
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, nullptr, false, true);
bool subset_markglyphsetsdef = false;
auto snapshot_version0 = c->serializer->snapshot ();
if (version.to_int () >= 0x00010002u)
{
if (unlikely (!c->serializer->embed (markGlyphSetsDef))) return_trace (false);
subset_markglyphsetsdef = out->markGlyphSetsDef.serialize_subset (c, markGlyphSetsDef, this);
}
bool subset_varstore = false;
auto snapshot_version2 = c->serializer->snapshot ();
if (version.to_int () >= 0x00010003u)
{
if (unlikely (!c->serializer->embed (varStore))) return_trace (false);
if (c->plan->all_axes_pinned)
out->varStore = 0;
else if (c->plan->normalized_coords)
@ -671,8 +707,10 @@ struct GDEFVersion1_2
out->version.minor = 3;
} else if (subset_markglyphsetsdef) {
out->version.minor = 2;
c->serializer->revert (snapshot_version2);
} else {
out->version.minor = 0;
c->serializer->revert (snapshot_version0);
}
return_trace (subset_glyphclassdef || subset_attachlist ||

@ -1371,10 +1371,20 @@ struct Lookup
if (lookupFlag & LookupFlag::UseMarkFilteringSet)
{
if (unlikely (!c->serializer->extend (out))) return_trace (false);
const HBUINT16 &markFilteringSet = StructAfter<HBUINT16> (subTable);
HBUINT16 &outMarkFilteringSet = StructAfter<HBUINT16> (out->subTable);
outMarkFilteringSet = markFilteringSet;
hb_codepoint_t *idx;
if (!c->plan->used_mark_sets_map.has (markFilteringSet, &idx))
{
unsigned new_flag = lookupFlag;
new_flag &= ~LookupFlag::UseMarkFilteringSet;
out->lookupFlag = new_flag;
}
else
{
if (unlikely (!c->serializer->extend (out))) return_trace (false);
HBUINT16 &outMarkFilteringSet = StructAfter<HBUINT16> (out->subTable);
outMarkFilteringSet = *idx;
}
}
// Always keep the lookup even if it's empty. The rest of layout subsetting depends on lookup

@ -70,6 +70,9 @@ HB_SUBSET_PLAN_MEMBER (hb_set_t, _glyphset_colred)
HB_SUBSET_PLAN_MEMBER (hb_map_t, gsub_lookups)
HB_SUBSET_PLAN_MEMBER (hb_map_t, gpos_lookups)
//use_mark_sets mapping: old->new
HB_SUBSET_PLAN_MEMBER (hb_map_t, used_mark_sets_map)
//active langsys we'd like to retain
HB_SUBSET_PLAN_MEMBER (hb_hashmap_t E(<unsigned, hb::unique_ptr<hb_set_t>>), gsub_langsys)
HB_SUBSET_PLAN_MEMBER (hb_hashmap_t E(<unsigned, hb::unique_ptr<hb_set_t>>), gpos_langsys)

@ -465,6 +465,24 @@ _math_closure (hb_subset_plan_t *plan,
math.destroy ();
}
static inline void
_remap_used_mark_sets (hb_subset_plan_t *plan,
hb_map_t& used_mark_sets_map)
{
hb_blob_ptr_t<OT::GDEF> gdef = plan->source_table<OT::GDEF> ();
if (!gdef->has_data () || !gdef->has_mark_glyph_sets ())
{
gdef.destroy ();
return;
}
hb_set_t used_mark_sets;
gdef->get_mark_glyph_sets ().collect_used_mark_sets (plan->_glyphset_gsub, used_mark_sets);
gdef.destroy ();
_remap_indexes (&used_mark_sets, &used_mark_sets_map);
}
static inline void
_remove_invalid_gids (hb_set_t *glyphs,
@ -1160,6 +1178,9 @@ hb_subset_plan_t::hb_subset_plan_t (hb_face_t *face,
for (auto &v : bounds_height_vec)
v = 0xFFFFFFFF;
if (!drop_tables.has (HB_OT_TAG_GDEF))
_remap_used_mark_sets (this, used_mark_sets_map);
if (unlikely (in_error ()))
return;

@ -73,7 +73,6 @@ EXTRA_DIST += \
expected/collect_name_ids \
expected/instantiate_colrv1 \
expected/instantiate_cff2_update_metrics \
expected/empty_region_vardata \
fonts \
profiles \
$(NULL)

@ -64,7 +64,6 @@ TESTS = \
tests/collect_name_ids.tests \
tests/instantiate_colrv1.tests \
tests/instantiate_cff2_update_metrics.tests \
tests/empty_region_vardata.tests \
$(NULL)
# TODO: re-enable once colrv1 subsetting is stabilized.

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save