[subset] place the gdef var store at the end of the GDEF table.

It appears that some font processors assume it is the last sub table.
pull/4640/head
Garret Rieger 11 months ago
parent 990fb14d78
commit 7145607149
  1. 38
      src/OT/Layout/GDEF/GDEF.hh
  2. BIN
      test/subset/data/expected/apply_cvar_delta/Comfortaa-Regular-new.default.retain-all-codepoint.wght=700.ttf
  3. BIN
      test/subset/data/expected/colrv1_copy_varstore/Foldit.default.retain-all-codepoint.ttf
  4. BIN
      test/subset/data/expected/colrv1_copy_varstore/Foldit.drop-hints-retain-gids.retain-all-codepoint.ttf
  5. BIN
      test/subset/data/expected/colrv1_copy_varstore/Foldit.drop-hints.retain-all-codepoint.ttf
  6. BIN
      test/subset/data/expected/colrv1_copy_varstore/Foldit.retain-gids.retain-all-codepoint.ttf
  7. BIN
      test/subset/data/expected/full_instance/Roboto-Variable.default.retain-all-codepoint.wght=150,wdth=80.ttf
  8. BIN
      test/subset/data/expected/full_instance/Roboto-Variable.default.retain-all-codepoint.wght=300,wdth=90.ttf
  9. BIN
      test/subset/data/expected/full_instance/Roboto-Variable.no-prune-unicode-ranges.retain-all-codepoint.wght=150,wdth=80.ttf
  10. BIN
      test/subset/data/expected/full_instance/Roboto-Variable.no-prune-unicode-ranges.retain-all-codepoint.wght=300,wdth=90.ttf
  11. BIN
      test/subset/data/expected/layout.context_format2/NotoSansNewa-Regular.layout-test-retain-gids.retain-all-codepoint.ttf
  12. BIN
      test/subset/data/expected/layout.context_format2/NotoSansNewa-Regular.layout-test.retain-all-codepoint.ttf
  13. BIN
      test/subset/data/expected/layout.drop_feature/SpectralSC-ExtraLightItalic.default.retain-all-codepoint.ttf
  14. BIN
      test/subset/data/expected/layout.drop_feature/SpectralSC-ExtraLightItalic.glyph-names.retain-all-codepoint.ttf
  15. BIN
      test/subset/data/expected/layout.drop_feature/SpectralSC-ExtraLightItalic.notdef-outline.retain-all-codepoint.ttf
  16. BIN
      test/subset/data/expected/layout.empty_ligature_offset/AnekBangla-latin-subset.default.retain-all-codepoint.ttf
  17. BIN
      test/subset/data/expected/layout.gdef/Roboto-Regular.default.1E00,303.ttf
  18. BIN
      test/subset/data/expected/layout.gdef/Roboto-Regular.default.303.ttf
  19. BIN
      test/subset/data/expected/layout.gdef/Roboto-Regular.default.309,20,30F.ttf
  20. BIN
      test/subset/data/expected/layout.gdef/Roboto-Regular.default.323.ttf
  21. BIN
      test/subset/data/expected/layout.gdef/Roboto-Regular.drop-hints.1E00,303.ttf
  22. BIN
      test/subset/data/expected/layout.gdef/Roboto-Regular.drop-hints.303.ttf
  23. BIN
      test/subset/data/expected/layout.gdef/Roboto-Regular.drop-hints.309,20,30F.ttf
  24. BIN
      test/subset/data/expected/layout.gdef/Roboto-Regular.drop-hints.323.ttf
  25. BIN
      test/subset/data/expected/layout.gdef/Roboto-Regular.keep-gdef-gpos.1E00,303.ttf
  26. BIN
      test/subset/data/expected/layout.gdef/Roboto-Regular.keep-gdef-gpos.303.ttf
  27. BIN
      test/subset/data/expected/layout.gdef/Roboto-Regular.keep-gdef-gpos.309,20,30F.ttf
  28. BIN
      test/subset/data/expected/layout.gdef/Roboto-Regular.keep-gdef-gpos.323.ttf
  29. BIN
      test/subset/data/expected/layout.notonastaliqurdu/NotoNastaliqUrdu-Regular.default.627,644,623,62D,644,627,645,2E.ttf
  30. BIN
      test/subset/data/expected/layout.notonastaliqurdu/NotoNastaliqUrdu-Regular.default.627,644,62D,628.ttf
  31. BIN
      test/subset/data/expected/layout.notonastaliqurdu/NotoNastaliqUrdu-Regular.default.633,6D2.ttf
  32. BIN
      test/subset/data/expected/layout.notonastaliqurdu/NotoNastaliqUrdu-Regular.default.63A,64A,631.ttf
  33. BIN
      test/subset/data/expected/layout.notonastaliqurdu/NotoNastaliqUrdu-Regular.default.retain-all-codepoint.ttf
  34. BIN
      test/subset/data/expected/layout.notonastaliqurdu/NotoNastaliqUrdu-Regular.retain-gids.627,644,623,62D,644,627,645,2E.ttf
  35. BIN
      test/subset/data/expected/layout.notonastaliqurdu/NotoNastaliqUrdu-Regular.retain-gids.627,644,62D,628.ttf
  36. BIN
      test/subset/data/expected/layout.notonastaliqurdu/NotoNastaliqUrdu-Regular.retain-gids.633,6D2.ttf
  37. BIN
      test/subset/data/expected/layout.notonastaliqurdu/NotoNastaliqUrdu-Regular.retain-gids.63A,64A,631.ttf
  38. BIN
      test/subset/data/expected/layout.notonastaliqurdu/NotoNastaliqUrdu-Regular.retain-gids.retain-all-codepoint.ttf

@ -663,19 +663,12 @@ struct GDEFVersion1_2
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_markattachclassdef = out->markAttachClassDef.serialize_subset (c, markAttachClassDef, this, nullptr, false, true);
bool subset_markglyphsetsdef = false;
// Serialize var store first (if it's needed) so that it's serialized last. Some font parsers assume
// that varstore runs to the end of the GDEF table.
// TODO(garretrieger): add a virtual link from all non-var store sub tables to the var store.
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);
}
if (unlikely (version.to_int () >= 0x00010002u && !c->serializer->embed (markGlyphSetsDef)))
return_trace (false);
bool subset_varstore = false;
auto snapshot_version2 = c->serializer->snapshot ();
@ -705,18 +698,33 @@ struct GDEFVersion1_2
}
out->version.major = version.major;
out->version.minor = version.minor;
if (!subset_varstore && version.to_int () >= 0x00010002u) {
c->serializer->revert (snapshot_version2);
}
bool subset_markglyphsetsdef = false;
if (version.to_int () >= 0x00010002u)
{
subset_markglyphsetsdef = out->markGlyphSetsDef.serialize_subset (c, markGlyphSetsDef, this);
}
if (subset_varstore)
{
out->version.minor = 3;
c->plan->has_gdef_varstore = true;
} else if (subset_markglyphsetsdef) {
out->version.minor = 2;
c->serializer->revert (snapshot_version2);
out->version.minor = 2;
} else {
out->version.minor = 0;
c->serializer->revert (snapshot_version0);
}
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_markattachclassdef = out->markAttachClassDef.serialize_subset (c, markAttachClassDef, this, nullptr, false, true);
bool subset_ligcaretlist = out->ligCaretList.serialize_subset (c, ligCaretList, this);
return_trace (subset_glyphclassdef || subset_attachlist ||
@ -1013,7 +1021,7 @@ struct GDEF
if (!has_var_store ()) return;
const ItemVariationStore &var_store = get_var_store ();
float *store_cache = var_store.create_cache ();
unsigned new_major = 0, new_minor = 0;
unsigned last_major = (layout_variation_indices->get_min ()) >> 16;
for (unsigned idx : layout_variation_indices->iter ())

Loading…
Cancel
Save