[subset] Add some basic tests for a provided glyph map.

pull/4221/head
Garret Rieger 2 years ago
parent 98e73192f4
commit 77a8155425
  1. 9
      src/hb-subset-input.cc
  2. 10
      src/hb-subset-plan.cc
  3. BIN
      test/subset/data/expected/glyph_map/Roboto-Regular.glyph_map_roboto.41,43,61,66,69.ttf
  4. BIN
      test/subset/data/expected/glyph_map/Roboto-Regular.glyph_map_roboto_retain_gids.41,43,61,66,69.ttf
  5. 2
      test/subset/data/profiles/glyph_map_roboto.txt
  6. 4
      test/subset/data/profiles/glyph_map_roboto_retain_gids.txt
  7. 9
      test/subset/data/tests/glyph_map.tests
  8. 4
      test/subset/generate-expected-outputs.py

@ -547,13 +547,10 @@ HB_EXTERN void
hb_subset_input_set_old_to_new_glyph_mapping (hb_subset_input_t *input,
const hb_map_t* mapping)
{
hb_set_t new_gids;
for (auto gid : mapping->values())
{
hb_set_t new_gids(mapping->values());
if (new_gids.get_population() != mapping->get_population())
// Mapping cannot map multiple old gids to the same new gid.
if (new_gids.has(gid)) return;
new_gids.add(gid);
}
return;
input->glyph_map = *mapping;
}

@ -782,10 +782,16 @@ _create_old_gid_to_new_gid_map (const hb_face_t *face,
if (*requested_glyph_map)
{
hb_codepoint_t max_glyph = HB_SET_VALUE_INVALID;
hb_codepoint_t max_glyph = 0;
hb_set_t remaining;
for (auto old_gid : all_gids_to_retain->iter ())
{
if (old_gid == 0) {
reverse_glyph_map->set(0, 0);
continue;
}
hb_codepoint_t* new_gid;
if (!requested_glyph_map->has (old_gid, &new_gid))
{
@ -793,7 +799,7 @@ _create_old_gid_to_new_gid_map (const hb_face_t *face,
continue;
}
if (*new_gid > max_glyph || max_glyph == HB_SET_VALUE_INVALID)
if (*new_gid > max_glyph)
max_glyph = *new_gid;
reverse_glyph_map->set (*new_gid, old_gid);
}

@ -0,0 +1,2 @@
--gid-map=37:1,39:2,69:3,74:4,77:5
--layout-features+=c2sc

@ -0,0 +1,4 @@
--gid-map=37:37,39:39,69:69,74:74,77:77,444:444,446:446,561:561,563:563
--gids=444,446,561,563
--layout-features+=c2sc
--retain-gids

@ -0,0 +1,9 @@
FONTS:
Roboto-Regular.ttf
PROFILES:
glyph_map_roboto.txt
glyph_map_roboto_retain_gids.txt
SUBSETS:
ACafi

@ -51,7 +51,9 @@ def generate_expected_output(input_file, unicodes, profile_flags, instance_flags
if unicodes != "":
args.extend(["--unicodes=%s" % unicodes,])
args.extend(profile_flags)
# --gid-map is unsupported in fonttools so don't send it. Tests using
# it are crafted to work without fonttools knowing about the flag.
args.extend([f for f in profile_flags if not f.startswith("--gid-map")])
if not no_fonttools:
check_call(args)

Loading…
Cancel
Save