[subset] Add one ttf file with fvar/STAT tables to integration test

Ignore gvar/MVAR/HVAR table
add support for --nameIDs=* option
pull/1723/head
Qunxin Liu 6 years ago committed by Garret Rieger
parent a03ed95e7d
commit 993d81b9c5
  1. 27
      src/hb-ot-cmap-table.hh
  2. 2
      src/hb-ot-stat-table.hh
  3. 1
      src/hb-subset-input.cc
  4. 6
      src/hb-subset-plan.cc
  5. 2
      test/api/hb-subset-test.h
  6. BIN
      test/subset/data/expected/basics/Comfortaa-Regular-new.default.61,62,63.ttf
  7. BIN
      test/subset/data/expected/basics/Comfortaa-Regular-new.default.61,63.ttf
  8. BIN
      test/subset/data/expected/basics/Comfortaa-Regular-new.default.61.ttf
  9. BIN
      test/subset/data/expected/basics/Comfortaa-Regular-new.default.62.ttf
  10. BIN
      test/subset/data/expected/basics/Comfortaa-Regular-new.default.63.ttf
  11. BIN
      test/subset/data/expected/basics/Comfortaa-Regular-new.drop-hints-retain-gids.61,62,63.ttf
  12. BIN
      test/subset/data/expected/basics/Comfortaa-Regular-new.drop-hints-retain-gids.61,63.ttf
  13. BIN
      test/subset/data/expected/basics/Comfortaa-Regular-new.drop-hints-retain-gids.61.ttf
  14. BIN
      test/subset/data/expected/basics/Comfortaa-Regular-new.drop-hints-retain-gids.62.ttf
  15. BIN
      test/subset/data/expected/basics/Comfortaa-Regular-new.drop-hints-retain-gids.63.ttf
  16. BIN
      test/subset/data/expected/basics/Comfortaa-Regular-new.drop-hints.61,62,63.ttf
  17. BIN
      test/subset/data/expected/basics/Comfortaa-Regular-new.drop-hints.61,63.ttf
  18. BIN
      test/subset/data/expected/basics/Comfortaa-Regular-new.drop-hints.61.ttf
  19. BIN
      test/subset/data/expected/basics/Comfortaa-Regular-new.drop-hints.62.ttf
  20. BIN
      test/subset/data/expected/basics/Comfortaa-Regular-new.drop-hints.63.ttf
  21. BIN
      test/subset/data/expected/basics/Comfortaa-Regular-new.name-ids.61,62,63.ttf
  22. BIN
      test/subset/data/expected/basics/Comfortaa-Regular-new.name-ids.61,63.ttf
  23. BIN
      test/subset/data/expected/basics/Comfortaa-Regular-new.name-ids.61.ttf
  24. BIN
      test/subset/data/expected/basics/Comfortaa-Regular-new.name-ids.62.ttf
  25. BIN
      test/subset/data/expected/basics/Comfortaa-Regular-new.name-ids.63.ttf
  26. BIN
      test/subset/data/expected/basics/Comfortaa-Regular-new.retain-gids.61,62,63.ttf
  27. BIN
      test/subset/data/expected/basics/Comfortaa-Regular-new.retain-gids.61,63.ttf
  28. BIN
      test/subset/data/expected/basics/Comfortaa-Regular-new.retain-gids.61.ttf
  29. BIN
      test/subset/data/expected/basics/Comfortaa-Regular-new.retain-gids.62.ttf
  30. BIN
      test/subset/data/expected/basics/Comfortaa-Regular-new.retain-gids.63.ttf
  31. BIN
      test/subset/data/expected/cff-full-font/SourceSansPro-Regular.default.1FC,21,41,20,62,63.otf
  32. BIN
      test/subset/data/expected/cff-full-font/SourceSansPro-Regular.default.61,62,63.otf
  33. BIN
      test/subset/data/expected/cff-full-font/SourceSansPro-Regular.default.D7,D8,D9,DA,DE.otf
  34. BIN
      test/subset/data/expected/cff-full-font/SourceSansPro-Regular.desubroutinize-retain-gids.1FC,21,41,20,62,63.otf
  35. BIN
      test/subset/data/expected/cff-full-font/SourceSansPro-Regular.desubroutinize-retain-gids.61,62,63.otf
  36. BIN
      test/subset/data/expected/cff-full-font/SourceSansPro-Regular.desubroutinize-retain-gids.D7,D8,D9,DA,DE.otf
  37. BIN
      test/subset/data/expected/cff-full-font/SourceSansPro-Regular.desubroutinize.1FC,21,41,20,62,63.otf
  38. BIN
      test/subset/data/expected/cff-full-font/SourceSansPro-Regular.desubroutinize.61,62,63.otf
  39. BIN
      test/subset/data/expected/cff-full-font/SourceSansPro-Regular.desubroutinize.D7,D8,D9,DA,DE.otf
  40. BIN
      test/subset/data/expected/cff-full-font/SourceSansPro-Regular.drop-hints-desubroutinize-retain-gids.1FC,21,41,20,62,63.otf
  41. BIN
      test/subset/data/expected/cff-full-font/SourceSansPro-Regular.drop-hints-desubroutinize-retain-gids.61,62,63.otf
  42. BIN
      test/subset/data/expected/cff-full-font/SourceSansPro-Regular.drop-hints-desubroutinize-retain-gids.D7,D8,D9,DA,DE.otf
  43. BIN
      test/subset/data/expected/cff-full-font/SourceSansPro-Regular.drop-hints-desubroutinize.1FC,21,41,20,62,63.otf
  44. BIN
      test/subset/data/expected/cff-full-font/SourceSansPro-Regular.drop-hints-desubroutinize.61,62,63.otf
  45. BIN
      test/subset/data/expected/cff-full-font/SourceSansPro-Regular.drop-hints-desubroutinize.D7,D8,D9,DA,DE.otf
  46. BIN
      test/subset/data/expected/cff-full-font/SourceSansPro-Regular.drop-hints-retain-gids.1FC,21,41,20,62,63.otf
  47. BIN
      test/subset/data/expected/cff-full-font/SourceSansPro-Regular.drop-hints-retain-gids.61,62,63.otf
  48. BIN
      test/subset/data/expected/cff-full-font/SourceSansPro-Regular.drop-hints-retain-gids.D7,D8,D9,DA,DE.otf
  49. BIN
      test/subset/data/expected/cff-full-font/SourceSansPro-Regular.drop-hints.1FC,21,41,20,62,63.otf
  50. BIN
      test/subset/data/expected/cff-full-font/SourceSansPro-Regular.drop-hints.61,62,63.otf
  51. BIN
      test/subset/data/expected/cff-full-font/SourceSansPro-Regular.drop-hints.D7,D8,D9,DA,DE.otf
  52. BIN
      test/subset/data/expected/cff-full-font/SourceSansPro-Regular.retain-gids.1FC,21,41,20,62,63.otf
  53. BIN
      test/subset/data/expected/cff-full-font/SourceSansPro-Regular.retain-gids.61,62,63.otf
  54. BIN
      test/subset/data/expected/cff-full-font/SourceSansPro-Regular.retain-gids.D7,D8,D9,DA,DE.otf
  55. BIN
      test/subset/data/expected/full-font/Roboto-Regular.default.1FC,21,41,20,62,63.ttf
  56. BIN
      test/subset/data/expected/full-font/Roboto-Regular.default.61,62,63.ttf
  57. BIN
      test/subset/data/expected/full-font/Roboto-Regular.default.D7,D8,D9,DA,DE.ttf
  58. BIN
      test/subset/data/expected/full-font/Roboto-Regular.drop-hints.1FC,21,41,20,62,63.ttf
  59. BIN
      test/subset/data/expected/full-font/Roboto-Regular.drop-hints.61,62,63.ttf
  60. BIN
      test/subset/data/expected/full-font/Roboto-Regular.drop-hints.D7,D8,D9,DA,DE.ttf
  61. BIN
      test/subset/data/expected/japanese/Mplus1p-Regular.default.3042,3044,3046,3048,304A,304B.ttf
  62. BIN
      test/subset/data/expected/japanese/Mplus1p-Regular.default.3042,3044,3046,73E0,5EA6,8F38.ttf
  63. BIN
      test/subset/data/expected/japanese/Mplus1p-Regular.default.61,63,65,6B.ttf
  64. BIN
      test/subset/data/expected/japanese/Mplus1p-Regular.default.660E,6975,73E0,5EA6,8F38,6E05.ttf
  65. BIN
      test/subset/data/expected/japanese/Mplus1p-Regular.default.660E.ttf
  66. BIN
      test/subset/data/expected/japanese/Mplus1p-Regular.drop-hints.3042,3044,3046,3048,304A,304B.ttf
  67. BIN
      test/subset/data/expected/japanese/Mplus1p-Regular.drop-hints.3042,3044,3046,73E0,5EA6,8F38.ttf
  68. BIN
      test/subset/data/expected/japanese/Mplus1p-Regular.drop-hints.61,63,65,6B.ttf
  69. BIN
      test/subset/data/expected/japanese/Mplus1p-Regular.drop-hints.660E,6975,73E0,5EA6,8F38,6E05.ttf
  70. BIN
      test/subset/data/expected/japanese/Mplus1p-Regular.drop-hints.660E.ttf
  71. BIN
      test/subset/data/fonts/Comfortaa-Regular-new.ttf
  72. 1
      test/subset/data/tests/basics.tests
  73. 3
      test/subset/generate-expected-outputs.py
  74. 3
      test/subset/run-tests.py
  75. 23
      util/options-subset.cc

@ -863,6 +863,7 @@ struct cmap
if (unlikely (!CmapSubtableFormat4::create_sub_table_plan (plan, &cmap_plan->format4_segments)))
return false;
if (!find_subtable (12)) return true;
return CmapSubtableFormat12::create_sub_table_plan (plan, &cmap_plan->format12_groups);
}
@ -881,8 +882,7 @@ struct cmap
table->version = 0;
if (unlikely (!table->encodingRecord.serialize (&c, /* numTables */ 3)))
return false;
if (unlikely (!table->encodingRecord.serialize (&c, /* numTables */ cmap_subset_plan.format12_groups ? 3 : 2))) return false;
// TODO(grieger): Convert the below to a for loop
@ -897,9 +897,12 @@ struct cmap
format4_plat3_rec.encodingID = 1; // Unicode BMP
// Format 12 Encoding Record
EncodingRecord &format12_rec = table->encodingRecord[2];
format12_rec.platformID = 3; // Windows
format12_rec.encodingID = 10; // Unicode UCS-4
if (cmap_subset_plan.format12_groups)
{
EncodingRecord &format12_rec = table->encodingRecord[2];
format12_rec.platformID = 3; // Windows
format12_rec.encodingID = 10; // Unicode UCS-4
}
// Write out format 4 sub table
{
@ -913,7 +916,9 @@ struct cmap
}
// Write out format 12 sub table.
if (cmap_subset_plan.format12_groups)
{
EncodingRecord &format12_rec = table->encodingRecord[2];
CmapSubtable &subtable = format12_rec.subtable.serialize (&c, table);
subtable.u.format = 12;
@ -1154,6 +1159,18 @@ struct cmap
return &(this+result.subtable);
}
bool find_subtable (unsigned format) const
{
auto it =
+ hb_iter (encodingRecord)
| hb_map (&EncodingRecord::subtable)
| hb_map (hb_add (this))
| hb_filter ([&] (const CmapSubtable& _) { return _.u.format == format; })
;
return it.len ();
}
public:
bool sanitize (hb_sanitize_context_t *c) const

@ -289,7 +289,7 @@ struct STAT
;
+ get_axis_value_offsets ()
| hb_map (hb_add (this))
| hb_map (hb_add (&(this + offsetToAxisValueOffsets)))
| hb_map (&AxisValue::get_value_name_id)
| hb_sink (nameids_to_retain)
;

@ -45,6 +45,7 @@ hb_subset_input_create_or_fail ()
input->unicodes = hb_set_create ();
input->glyphs = hb_set_create ();
input->name_ids = hb_set_create ();
hb_set_add_range (input->name_ids, 0, 6);
input->drop_tables = hb_set_create ();
input->drop_hints = false;
input->desubroutinize = false;

@ -234,12 +234,8 @@ hb_subset_plan_create (hb_face_t *face,
plan->retain_gids = input->retain_gids;
plan->unicodes = hb_set_create ();
plan->name_ids = hb_set_reference (input->name_ids);
plan->drop_tables = hb_set_reference (input->drop_tables);
/* TODO Clean this up... */
if (hb_set_is_empty (plan->name_ids))
hb_set_add_range (plan->name_ids, 0, 0x7FFF);
_nameid_closure (face, plan->name_ids);
plan->drop_tables = hb_set_reference (input->drop_tables);
plan->source = hb_face_reference (face);
plan->dest = hb_face_builder_create ();

@ -70,7 +70,7 @@ hb_subset_test_create_input_from_nameids (const hb_set_t *name_ids)
{
hb_subset_input_t *input = hb_subset_input_create_or_fail ();
hb_set_t * input_name_ids = hb_subset_input_nameid_set (input);
hb_set_union (input_name_ids, name_ids);
hb_set_set (input_name_ids, name_ids);
return input;
}

@ -1,5 +1,6 @@
FONTS:
Roboto-Regular.abc.ttf
Comfortaa-Regular-new.ttf
PROFILES:
default.txt

@ -20,11 +20,10 @@ def usage():
def generate_expected_output(input_file, unicodes, profile_flags, output_path):
args = ["fonttools", "subset", input_file]
args.extend(["--notdef-outline",
"--name-IDs=*",
"--name-languages=*",
"--name-legacy",
"--drop-tables+=DSIG,GPOS,GSUB,GDEF",
"--layout-features=*",
"--drop-tables+=DSIG,GPOS,GSUB,GDEF,gvar,avar,MVAR,HVAR",
"--unicodes=%s" % unicodes,
"--output-file=%s" % output_path])
args.extend(profile_flags)

@ -66,7 +66,8 @@ def run_test(test, should_check_ots):
cli_args = [hb_subset,
"--font-file=" + test.font_path,
"--output-file=" + out_file,
"--unicodes=%s" % test.unicodes ()]
"--unicodes=%s" % test.unicodes (),
"--drop-tables+=DSIG,GPOS,GSUB,GDEF,gvar,avar,MVAR,HVAR"]
cli_args.extend (test.get_profile_flags ())
print (' '.join (cli_args))
_, return_code = cmd (cli_args)

@ -29,7 +29,7 @@
#include "hb-subset-input.hh"
static gboolean
parse_nameids (const char *name G_GNUC_UNUSED,
parse_nameids (const char *name,
const char *arg,
gpointer data,
GError **error G_GNUC_UNUSED)
@ -37,7 +37,19 @@ parse_nameids (const char *name G_GNUC_UNUSED,
subset_options_t *subset_opts = (subset_options_t *) data;
hb_set_t *name_ids = subset_opts->input->name_ids;
hb_set_clear (name_ids);
char last_name_char = name[strlen (name) - 1];
if (last_name_char != '+' && last_name_char != '-')
hb_set_clear (name_ids);
if (0 == strcmp (arg, "*"))
{
if (last_name_char == '-')
hb_set_del_range (name_ids, 0, 0x7FFF);
else
hb_set_add_range (name_ids, 0, 0x7FFF);
return true;
}
char *s = (char *) arg;
char *p;
@ -59,7 +71,12 @@ parse_nameids (const char *name G_GNUC_UNUSED,
return false;
}
hb_set_add (name_ids, u);
if (last_name_char != '-')
{
hb_set_add (name_ids, u);
} else {
hb_set_del (name_ids, u);
}
s = p;
}

Loading…
Cancel
Save