[subset] add --hinting flag

This commit is contained in:
Rod Sheeter 2018-02-21 10:34:00 -08:00
parent 7ecca8c0a8
commit 0bd100e144
4 changed files with 35 additions and 1 deletions

View File

@ -43,6 +43,7 @@ struct hb_subset_input_t {
hb_set_t *unicodes; hb_set_t *unicodes;
hb_set_t *glyphs; hb_set_t *glyphs;
hb_bool_t retain_hints;
/* TODO /* TODO
* *
* features * features

View File

@ -29,6 +29,7 @@
#include "main-font-text.hh" #include "main-font-text.hh"
#include "hb-subset.h" #include "hb-subset.h"
#include "hb-subset-private.hh"
/* /*
* Command line interface to the harfbuzz font subsetter. * Command line interface to the harfbuzz font subsetter.
@ -37,7 +38,7 @@
struct subset_consumer_t struct subset_consumer_t
{ {
subset_consumer_t (option_parser_t *parser) subset_consumer_t (option_parser_t *parser)
: failed (false), options (parser), font (nullptr), input (nullptr) {} : failed (false), options (parser), subset_options (parser), font (nullptr), input (nullptr) {}
void init (hb_buffer_t *buffer_, void init (hb_buffer_t *buffer_,
const font_options_t *font_opts) const font_options_t *font_opts)
@ -89,6 +90,8 @@ struct subset_consumer_t
void finish (const font_options_t *font_opts) void finish (const font_options_t *font_opts)
{ {
input->retain_hints = subset_options.hinting;
hb_subset_profile_t *subset_profile = hb_subset_profile_create(); hb_subset_profile_t *subset_profile = hb_subset_profile_create();
hb_face_t *face = hb_font_get_face (font); hb_face_t *face = hb_font_get_face (font);
@ -111,6 +114,7 @@ struct subset_consumer_t
private: private:
output_options_t options; output_options_t options;
subset_options_t subset_options;
hb_font_t *font; hb_font_t *font;
hb_subset_input_t *input; hb_subset_input_t *input;
}; };

View File

@ -986,3 +986,18 @@ format_options_t::serialize_buffer_of_glyphs (hb_buffer_t *buffer,
serialize_glyphs (buffer, font, output_format, format_flags, gs); serialize_glyphs (buffer, font, output_format, format_flags, gs);
g_string_append_c (gs, '\n'); g_string_append_c (gs, '\n');
} }
void
subset_options_t::add_options (option_parser_t *parser)
{
GOptionEntry entries[] =
{
{"hinting", 0, 0, G_OPTION_ARG_NONE, &this->hinting, "Whether to retain or drop hints", nullptr},
{nullptr}
};
parser->add_group (entries,
"subset",
"Subset options:",
"Options subsetting",
this);
}

View File

@ -649,6 +649,20 @@ struct format_options_t : option_group_t
hb_bool_t trace; hb_bool_t trace;
}; };
struct subset_options_t : option_group_t
{
subset_options_t (option_parser_t *parser)
{
hinting = true;
add_options (parser);
}
void add_options (option_parser_t *parser);
hb_bool_t hinting;
};
/* fallback implementation for scalbn()/scalbnf() for pre-2013 MSVC */ /* fallback implementation for scalbn()/scalbnf() for pre-2013 MSVC */
#if defined (_MSC_VER) && (_MSC_VER < 1800) #if defined (_MSC_VER) && (_MSC_VER < 1800)