[subset] Add drop-tables option to hb-subset util.
This commit is contained in:
parent
3be0ffe45d
commit
67064294a0
|
@ -94,6 +94,7 @@ struct subset_consumer_t
|
||||||
hb_subset_input_set_retain_gids (input, subset_options.retain_gids);
|
hb_subset_input_set_retain_gids (input, subset_options.retain_gids);
|
||||||
hb_subset_input_set_desubroutinize (input, subset_options.desubroutinize);
|
hb_subset_input_set_desubroutinize (input, subset_options.desubroutinize);
|
||||||
hb_set_set (hb_subset_input_nameid_set (input), subset_options.name_ids);
|
hb_set_set (hb_subset_input_nameid_set (input), subset_options.name_ids);
|
||||||
|
hb_set_set (hb_subset_input_drop_tables_set (input), subset_options.drop_tables);
|
||||||
|
|
||||||
hb_face_t *face = hb_font_get_face (font);
|
hb_face_t *face = hb_font_get_face (font);
|
||||||
|
|
||||||
|
|
|
@ -31,6 +31,8 @@
|
||||||
#endif
|
#endif
|
||||||
#include <hb-ot.h>
|
#include <hb-ot.h>
|
||||||
|
|
||||||
|
#define DELIMITERS "<+>{},;&#\\xXuUnNiI\n\t\v\f\r "
|
||||||
|
|
||||||
static struct supported_font_funcs_t {
|
static struct supported_font_funcs_t {
|
||||||
char name[4];
|
char name[4];
|
||||||
void (*func) (hb_font_t *);
|
void (*func) (hb_font_t *);
|
||||||
|
@ -352,7 +354,7 @@ parse_unicodes (const char *name G_GNUC_UNUSED,
|
||||||
|
|
||||||
while (s && *s)
|
while (s && *s)
|
||||||
{
|
{
|
||||||
while (*s && strchr ("<+>{},;&#\\xXuUnNiI\n\t\v\f\r ", *s))
|
while (*s && strchr (DELIMITERS, *s))
|
||||||
s++;
|
s++;
|
||||||
if (!*s)
|
if (!*s)
|
||||||
break;
|
break;
|
||||||
|
@ -985,7 +987,7 @@ parse_nameids (const char *name G_GNUC_UNUSED,
|
||||||
|
|
||||||
while (s && *s)
|
while (s && *s)
|
||||||
{
|
{
|
||||||
while (*s && strchr ("<+>{},;&#\\xXuUnNiI\n\t\v\f\r ", *s))
|
while (*s && strchr (DELIMITERS, *s))
|
||||||
s++;
|
s++;
|
||||||
if (!*s)
|
if (!*s)
|
||||||
break;
|
break;
|
||||||
|
@ -1013,6 +1015,43 @@ parse_nameids (const char *name G_GNUC_UNUSED,
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
parse_drop_tables (const char *name G_GNUC_UNUSED,
|
||||||
|
const char *arg,
|
||||||
|
gpointer data,
|
||||||
|
GError **error G_GNUC_UNUSED)
|
||||||
|
{
|
||||||
|
subset_options_t *subset_opts = (subset_options_t *) data;
|
||||||
|
|
||||||
|
hb_set_clear (subset_opts->drop_tables);
|
||||||
|
char *s = (char *) arg;
|
||||||
|
|
||||||
|
while (s && *s)
|
||||||
|
{
|
||||||
|
while (*s && strchr (", ", *s))
|
||||||
|
s++;
|
||||||
|
if (!*s)
|
||||||
|
break;
|
||||||
|
|
||||||
|
char *p = s;
|
||||||
|
while (*p && !strchr (", ", *p))
|
||||||
|
p++;
|
||||||
|
|
||||||
|
if ((p - s) > 4) // Table tags are at most 4 bytes.
|
||||||
|
{
|
||||||
|
g_set_error (error, G_OPTION_ERROR, G_OPTION_ERROR_BAD_VALUE,
|
||||||
|
"Failed parsing table tag values at: '%s'", s);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
hb_tag_t tag = hb_tag_from_string (s, p -s);
|
||||||
|
hb_set_add (subset_opts->drop_tables, tag);
|
||||||
|
s = p;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
subset_options_t::add_options (option_parser_t *parser)
|
subset_options_t::add_options (option_parser_t *parser)
|
||||||
|
@ -1024,6 +1063,7 @@ subset_options_t::add_options (option_parser_t *parser)
|
||||||
{"retain-gids", 0, 0, G_OPTION_ARG_NONE, &this->retain_gids, "If set don't renumber glyph ids in the subset.", nullptr},
|
{"retain-gids", 0, 0, G_OPTION_ARG_NONE, &this->retain_gids, "If set don't renumber glyph ids in the subset.", nullptr},
|
||||||
{"desubroutinize", 0, 0, G_OPTION_ARG_NONE, &this->desubroutinize, "Remove CFF/CFF2 use of subroutines", nullptr},
|
{"desubroutinize", 0, 0, G_OPTION_ARG_NONE, &this->desubroutinize, "Remove CFF/CFF2 use of subroutines", nullptr},
|
||||||
{"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"},
|
||||||
|
{"drop-tables", 0, 0, G_OPTION_ARG_CALLBACK, (gpointer) &parse_drop_tables, "Drop the specified tables.", "list of string table tags."},
|
||||||
|
|
||||||
{nullptr}
|
{nullptr}
|
||||||
};
|
};
|
||||||
|
@ -1033,4 +1073,3 @@ subset_options_t::add_options (option_parser_t *parser)
|
||||||
"Options subsetting",
|
"Options subsetting",
|
||||||
this);
|
this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -678,6 +678,7 @@ struct subset_options_t : option_group_t
|
||||||
retain_gids = false;
|
retain_gids = false;
|
||||||
desubroutinize = false;
|
desubroutinize = false;
|
||||||
name_ids = hb_set_create ();
|
name_ids = hb_set_create ();
|
||||||
|
drop_tables = hb_set_create();
|
||||||
|
|
||||||
add_options (parser);
|
add_options (parser);
|
||||||
}
|
}
|
||||||
|
@ -685,6 +686,7 @@ struct subset_options_t : option_group_t
|
||||||
virtual ~subset_options_t ()
|
virtual ~subset_options_t ()
|
||||||
{
|
{
|
||||||
hb_set_destroy (name_ids);
|
hb_set_destroy (name_ids);
|
||||||
|
hb_set_destroy (drop_tables);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -695,6 +697,7 @@ struct subset_options_t : option_group_t
|
||||||
hb_bool_t retain_gids;
|
hb_bool_t retain_gids;
|
||||||
hb_bool_t desubroutinize;
|
hb_bool_t desubroutinize;
|
||||||
hb_set_t *name_ids;
|
hb_set_t *name_ids;
|
||||||
|
hb_set_t *drop_tables;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* fallback implementation for scalbn()/scalbnf() for pre-2013 MSVC */
|
/* fallback implementation for scalbn()/scalbnf() for pre-2013 MSVC */
|
||||||
|
|
Loading…
Reference in New Issue