From b83f25c749c219e2cb7ed6d819d638f97bf3ea62 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Wed, 11 Aug 2021 20:42:20 -0600 Subject: [PATCH] [util/hb-subset] Revamp option groups --- util/shape-options.hh | 3 ++- util/subset-options.hh | 59 +++++++++++++++++++++++++++++++++--------- 2 files changed, 49 insertions(+), 13 deletions(-) diff --git a/util/shape-options.hh b/util/shape-options.hh index c3dedb521..92d273174 100644 --- a/util/shape-options.hh +++ b/util/shape-options.hh @@ -432,7 +432,8 @@ shape_options_t::add_options (option_parser_t *parser) {"cluster-level", 0, 0, G_OPTION_ARG_INT, &this->cluster_level, "Cluster merging level (default: 0)", "0/1/2"}, {"normalize-glyphs",0, 0, G_OPTION_ARG_NONE, &this->normalize_glyphs, "Rearrange glyph clusters in nominal order", nullptr}, {"verify", 0, 0, G_OPTION_ARG_NONE, &this->verify, "Perform sanity checks on shaping results", nullptr}, - {"num-iterations", 'n', 0, G_OPTION_ARG_INT, &this->num_iterations, "Run shaper N times (default: 1)", "N"}, + {"num-iterations", 'n', G_OPTION_FLAG_IN_MAIN, + G_OPTION_ARG_INT, &this->num_iterations, "Run shaper N times (default: 1)", "N"}, {nullptr} }; parser->add_group (entries, diff --git a/util/subset-options.hh b/util/subset-options.hh index f2f85c215..6027cde94 100644 --- a/util/subset-options.hh +++ b/util/subset-options.hh @@ -325,16 +325,27 @@ parse_drop_tables (const char *name, void subset_options_t::add_options (option_parser_t *parser) { - GOptionEntry entries[] = + GOptionEntry glyphset_entries[] = { - {"no-hinting", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, (gpointer) &set_flag, "Whether to drop hints", nullptr}, - {"retain-gids", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, (gpointer) &set_flag, "If set don't renumber glyph ids in the subset.", nullptr}, {"gids", 0, 0, G_OPTION_ARG_CALLBACK, (gpointer) &parse_gids, "Specify glyph IDs or ranges to include in the subset", "list of comma/whitespace-separated int numbers or ranges"}, - {"desubroutinize", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, (gpointer) &set_flag, "Remove CFF/CFF2 use of subroutines", nullptr}, + // gids-file + // glyphs + // glyphs-file + // text + // text-file + {nullptr} + }; + parser->add_group (glyphset_entries, + "subset-glyphset", + "Subset glyph-set option:", + "Subsetting glyph-set options", + this); + + GOptionEntry other_entries[] = + { {"name-IDs", 0, 0, G_OPTION_ARG_CALLBACK, (gpointer) &parse_nameids, "Subset specified nameids", "list of int numbers"}, {"name-IDs-", 0, 0, G_OPTION_ARG_CALLBACK, (gpointer) &parse_nameids, "Subset specified nameids", "list of int numbers"}, {"name-IDs+", 0, 0, G_OPTION_ARG_CALLBACK, (gpointer) &parse_nameids, "Subset specified nameids", "list of int numbers"}, - {"name-legacy", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, (gpointer) &set_flag, "Keep legacy (non-Unicode) 'name' table entries", nullptr}, {"name-languages", 0, 0, G_OPTION_ARG_CALLBACK, (gpointer) &parse_name_languages, "Subset nameRecords with specified language IDs", "list of int numbers"}, {"name-languages-", 0, 0, G_OPTION_ARG_CALLBACK, (gpointer) &parse_name_languages, "Subset nameRecords with specified language IDs", "list of int numbers"}, {"name-languages+", 0, 0, G_OPTION_ARG_CALLBACK, (gpointer) &parse_name_languages, "Subset nameRecords with specified language IDs", "list of int numbers"}, @@ -344,9 +355,20 @@ subset_options_t::add_options (option_parser_t *parser) {"drop-tables", 0, 0, G_OPTION_ARG_CALLBACK, (gpointer) &parse_drop_tables, "Drop the specified tables.", "list of string table tags."}, {"drop-tables+", 0, 0, G_OPTION_ARG_CALLBACK, (gpointer) &parse_drop_tables, "Drop the specified tables.", "list of string table tags."}, {"drop-tables-", 0, 0, G_OPTION_ARG_CALLBACK, (gpointer) &parse_drop_tables, "Drop the specified tables.", "list of string table tags."}, - {"num-iterations", 'n', 0, G_OPTION_ARG_INT, - &this->num_iterations, - "Run subsetter N times (default: 1)", "N"}, + {nullptr} + }; + parser->add_group (other_entries, + "subset-other", + "Subset other option:", + "Subsetting other options", + this); + + GOptionEntry flag_entries[] = + { + {"no-hinting", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, (gpointer) &set_flag, "Whether to drop hints", nullptr}, + {"retain-gids", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, (gpointer) &set_flag, "If set don't renumber glyph ids in the subset.", nullptr}, + {"desubroutinize", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, (gpointer) &set_flag, "Remove CFF/CFF2 use of subroutines", nullptr}, + {"name-legacy", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, (gpointer) &set_flag, "Keep legacy (non-Unicode) 'name' table entries", nullptr}, {"set-overlaps-flag", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, (gpointer) &set_flag, "Set the overlaps flag on each glyph.", nullptr}, {"notdef-outline", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, (gpointer) &set_flag, "Keep the outline of \'.notdef\' glyph", nullptr}, @@ -354,10 +376,23 @@ subset_options_t::add_options (option_parser_t *parser) {"glyph-names", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, (gpointer) &set_flag, "Keep PS glyph names in TT-flavored fonts. ", nullptr}, {nullptr} }; - parser->add_group (entries, - "subset", - "Subset options:", - "Options subsetting", + parser->add_group (flag_entries, + "subset-flags", + "Subset boolean option:", + "Subsetting boolean options", + this); + + GOptionEntry app_entries[] = + { + {"num-iterations", 'n', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_INT, + &this->num_iterations, + "Run subsetter N times (default: 1)", "N"}, + {nullptr} + }; + parser->add_group (app_entries, + "subset-app", + "Subset app option:", + "Subsetting application options", this); }