diff --git a/src/hb-ot-layout-gpos-table.hh b/src/hb-ot-layout-gpos-table.hh index e0459c263..3e02931a5 100644 --- a/src/hb-ot-layout-gpos-table.hh +++ b/src/hb-ot-layout-gpos-table.hh @@ -1961,8 +1961,70 @@ struct MarkMarkPosFormat1 bool subset (hb_subset_context_t *c) const { TRACE_SUBSET (this); - // TODO(subset) - return_trace (false); + 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); + out->format = format; + + hb_map_t klass_mapping; + Markclass_closure_and_remap_indexes (this+mark1Coverage, this+mark1Array, glyphset, &klass_mapping); + + if (!klass_mapping.get_population ()) return_trace (false); + out->classCount = klass_mapping.get_population (); + + auto mark1_iter = + + hb_zip (this+mark1Coverage, this+mark1Array) + | hb_filter (glyphset, hb_first) + ; + + hb_sorted_vector_t new_coverage; + + mark1_iter + | hb_map (hb_first) + | hb_map (glyph_map) + | hb_sink (new_coverage) + ; + + if (!out->mark1Coverage.serialize (c->serializer, out) + .serialize (c->serializer, new_coverage.iter ())) + return_trace (false); + + out->mark1Array.serialize (c->serializer, out) + .serialize (c->serializer, &klass_mapping, &(this+mark1Array), + mark1_iter + | hb_map (hb_second)); +////// + unsigned mark2count = (this+mark2Array).rows; + auto mark2_iter = + + hb_zip (this+mark2Coverage, hb_range (mark2count)) + | hb_filter (glyphset, hb_first) + ; + + new_coverage.reset (); + + mark2_iter + | hb_map (hb_first) + | hb_map (glyph_map) + | hb_sink (new_coverage) + ; + + if (!out->mark2Coverage.serialize (c->serializer, out) + .serialize (c->serializer, new_coverage.iter ())) + return_trace (false); + + hb_sorted_vector_t mark2_indexes; + for (const unsigned row : + mark2_iter + | hb_map (hb_second)) + { + + hb_range ((unsigned) classCount) + | hb_filter (klass_mapping) + | hb_map ([&] (const unsigned col) { return row * (unsigned) classCount + col; }) + | hb_sink (mark2_indexes) + ; + } + out->mark2Array.serialize (c->serializer, out) + .serialize (c->serializer, mark2_iter.len (), &(this+mark2Array), mark2_indexes.iter ()); + + return_trace (true); } bool sanitize (hb_sanitize_context_t *c) const diff --git a/test/subset/data/Makefile.am b/test/subset/data/Makefile.am index 81aee9579..20705829a 100644 --- a/test/subset/data/Makefile.am +++ b/test/subset/data/Makefile.am @@ -17,6 +17,7 @@ EXTRA_DIST += \ expected/layout.gpos2 \ expected/layout.gpos3 \ expected/layout.gpos4 \ + expected/layout.gpos6 \ expected/layout.gsub6 \ expected/cmap \ expected/cmap14 \ diff --git a/test/subset/data/Makefile.sources b/test/subset/data/Makefile.sources index b5b4a1f37..2b57ef02f 100644 --- a/test/subset/data/Makefile.sources +++ b/test/subset/data/Makefile.sources @@ -9,6 +9,7 @@ TESTS = \ tests/layout.gpos2.tests \ tests/layout.gpos3.tests \ tests/layout.gpos4.tests \ + tests/layout.gpos6.tests \ tests/layout.gsub6.tests \ tests/cmap.tests \ tests/cmap14.tests \ diff --git a/test/subset/data/expected/layout.gpos6/gpos6_font1.keep-layout-retain-gids.41,42,43,44.otf b/test/subset/data/expected/layout.gpos6/gpos6_font1.keep-layout-retain-gids.41,42,43,44.otf new file mode 100644 index 000000000..92d1e28f9 Binary files /dev/null and b/test/subset/data/expected/layout.gpos6/gpos6_font1.keep-layout-retain-gids.41,42,43,44.otf differ diff --git a/test/subset/data/expected/layout.gpos6/gpos6_font1.keep-layout-retain-gids.41,42,43,45.otf b/test/subset/data/expected/layout.gpos6/gpos6_font1.keep-layout-retain-gids.41,42,43,45.otf new file mode 100644 index 000000000..28d5cb495 Binary files /dev/null and b/test/subset/data/expected/layout.gpos6/gpos6_font1.keep-layout-retain-gids.41,42,43,45.otf differ diff --git a/test/subset/data/expected/layout.gpos6/gpos6_font1.keep-layout-retain-gids.41,42,43.otf b/test/subset/data/expected/layout.gpos6/gpos6_font1.keep-layout-retain-gids.41,42,43.otf new file mode 100644 index 000000000..7d58a98f7 Binary files /dev/null and b/test/subset/data/expected/layout.gpos6/gpos6_font1.keep-layout-retain-gids.41,42,43.otf differ diff --git a/test/subset/data/expected/layout.gpos6/gpos6_font1.keep-layout-retain-gids.41,42.otf b/test/subset/data/expected/layout.gpos6/gpos6_font1.keep-layout-retain-gids.41,42.otf new file mode 100644 index 000000000..426108161 Binary files /dev/null and b/test/subset/data/expected/layout.gpos6/gpos6_font1.keep-layout-retain-gids.41,42.otf differ diff --git a/test/subset/data/expected/layout.gpos6/gpos6_font1.keep-layout-retain-gids.41,43,44,45,46.otf b/test/subset/data/expected/layout.gpos6/gpos6_font1.keep-layout-retain-gids.41,43,44,45,46.otf new file mode 100644 index 000000000..d944ebf92 Binary files /dev/null and b/test/subset/data/expected/layout.gpos6/gpos6_font1.keep-layout-retain-gids.41,43,44,45,46.otf differ diff --git a/test/subset/data/expected/layout.gpos6/gpos6_font1.keep-layout-retain-gids.41,43,44.otf b/test/subset/data/expected/layout.gpos6/gpos6_font1.keep-layout-retain-gids.41,43,44.otf new file mode 100644 index 000000000..7dc3d6211 Binary files /dev/null and b/test/subset/data/expected/layout.gpos6/gpos6_font1.keep-layout-retain-gids.41,43,44.otf differ diff --git a/test/subset/data/expected/layout.gpos6/gpos6_font1.keep-layout-retain-gids.41,43,45.otf b/test/subset/data/expected/layout.gpos6/gpos6_font1.keep-layout-retain-gids.41,43,45.otf new file mode 100644 index 000000000..f7727d4fd Binary files /dev/null and b/test/subset/data/expected/layout.gpos6/gpos6_font1.keep-layout-retain-gids.41,43,45.otf differ diff --git a/test/subset/data/expected/layout.gpos6/gpos6_font1.keep-layout-retain-gids.41,43.otf b/test/subset/data/expected/layout.gpos6/gpos6_font1.keep-layout-retain-gids.41,43.otf new file mode 100644 index 000000000..7e564d5d0 Binary files /dev/null and b/test/subset/data/expected/layout.gpos6/gpos6_font1.keep-layout-retain-gids.41,43.otf differ diff --git a/test/subset/data/expected/layout.gpos6/gpos6_font1.keep-layout-retain-gids.41.otf b/test/subset/data/expected/layout.gpos6/gpos6_font1.keep-layout-retain-gids.41.otf new file mode 100644 index 000000000..c9ae1c71f Binary files /dev/null and b/test/subset/data/expected/layout.gpos6/gpos6_font1.keep-layout-retain-gids.41.otf differ diff --git a/test/subset/data/expected/layout.gpos6/gpos6_font1.keep-layout-retain-gids.retain-all-codepoint.otf b/test/subset/data/expected/layout.gpos6/gpos6_font1.keep-layout-retain-gids.retain-all-codepoint.otf new file mode 100644 index 000000000..f63634252 Binary files /dev/null and b/test/subset/data/expected/layout.gpos6/gpos6_font1.keep-layout-retain-gids.retain-all-codepoint.otf differ diff --git a/test/subset/data/expected/layout.gpos6/gpos6_font1.keep-layout.41,42,43,44.otf b/test/subset/data/expected/layout.gpos6/gpos6_font1.keep-layout.41,42,43,44.otf new file mode 100644 index 000000000..106c55abc Binary files /dev/null and b/test/subset/data/expected/layout.gpos6/gpos6_font1.keep-layout.41,42,43,44.otf differ diff --git a/test/subset/data/expected/layout.gpos6/gpos6_font1.keep-layout.41,42,43,45.otf b/test/subset/data/expected/layout.gpos6/gpos6_font1.keep-layout.41,42,43,45.otf new file mode 100644 index 000000000..ba37625a1 Binary files /dev/null and b/test/subset/data/expected/layout.gpos6/gpos6_font1.keep-layout.41,42,43,45.otf differ diff --git a/test/subset/data/expected/layout.gpos6/gpos6_font1.keep-layout.41,42,43.otf b/test/subset/data/expected/layout.gpos6/gpos6_font1.keep-layout.41,42,43.otf new file mode 100644 index 000000000..8a6aa87e9 Binary files /dev/null and b/test/subset/data/expected/layout.gpos6/gpos6_font1.keep-layout.41,42,43.otf differ diff --git a/test/subset/data/expected/layout.gpos6/gpos6_font1.keep-layout.41,42.otf b/test/subset/data/expected/layout.gpos6/gpos6_font1.keep-layout.41,42.otf new file mode 100644 index 000000000..1b8a1cab1 Binary files /dev/null and b/test/subset/data/expected/layout.gpos6/gpos6_font1.keep-layout.41,42.otf differ diff --git a/test/subset/data/expected/layout.gpos6/gpos6_font1.keep-layout.41,43,44,45,46.otf b/test/subset/data/expected/layout.gpos6/gpos6_font1.keep-layout.41,43,44,45,46.otf new file mode 100644 index 000000000..09e27e695 Binary files /dev/null and b/test/subset/data/expected/layout.gpos6/gpos6_font1.keep-layout.41,43,44,45,46.otf differ diff --git a/test/subset/data/expected/layout.gpos6/gpos6_font1.keep-layout.41,43,44.otf b/test/subset/data/expected/layout.gpos6/gpos6_font1.keep-layout.41,43,44.otf new file mode 100644 index 000000000..48e8928e3 Binary files /dev/null and b/test/subset/data/expected/layout.gpos6/gpos6_font1.keep-layout.41,43,44.otf differ diff --git a/test/subset/data/expected/layout.gpos6/gpos6_font1.keep-layout.41,43,45.otf b/test/subset/data/expected/layout.gpos6/gpos6_font1.keep-layout.41,43,45.otf new file mode 100644 index 000000000..e4656fe02 Binary files /dev/null and b/test/subset/data/expected/layout.gpos6/gpos6_font1.keep-layout.41,43,45.otf differ diff --git a/test/subset/data/expected/layout.gpos6/gpos6_font1.keep-layout.41,43.otf b/test/subset/data/expected/layout.gpos6/gpos6_font1.keep-layout.41,43.otf new file mode 100644 index 000000000..5527d9ff4 Binary files /dev/null and b/test/subset/data/expected/layout.gpos6/gpos6_font1.keep-layout.41,43.otf differ diff --git a/test/subset/data/expected/layout.gpos6/gpos6_font1.keep-layout.41.otf b/test/subset/data/expected/layout.gpos6/gpos6_font1.keep-layout.41.otf new file mode 100644 index 000000000..c151b9d8a Binary files /dev/null and b/test/subset/data/expected/layout.gpos6/gpos6_font1.keep-layout.41.otf differ diff --git a/test/subset/data/expected/layout.gpos6/gpos6_font1.keep-layout.retain-all-codepoint.otf b/test/subset/data/expected/layout.gpos6/gpos6_font1.keep-layout.retain-all-codepoint.otf new file mode 100644 index 000000000..f63634252 Binary files /dev/null and b/test/subset/data/expected/layout.gpos6/gpos6_font1.keep-layout.retain-all-codepoint.otf differ diff --git a/test/subset/data/fonts/gpos6_font1.otf b/test/subset/data/fonts/gpos6_font1.otf new file mode 100644 index 000000000..fd640acb2 Binary files /dev/null and b/test/subset/data/fonts/gpos6_font1.otf differ diff --git a/test/subset/data/tests/layout.gpos6.tests b/test/subset/data/tests/layout.gpos6.tests new file mode 100644 index 000000000..d31e0d474 --- /dev/null +++ b/test/subset/data/tests/layout.gpos6.tests @@ -0,0 +1,18 @@ +FONTS: +gpos6_font1.otf + +PROFILES: +keep-layout.txt +keep-layout-retain-gids.txt + +SUBSETS: +A +AB +AC +ABC +ACE +ABCE +ACD +ACDEF +ABCD +*