[util] Move subset options into subset-options.hh

This commit is contained in:
Behdad Esfahbod 2021-08-06 23:03:30 -06:00
parent 370e961faf
commit 167f58a2ca
5 changed files with 48 additions and 43 deletions

View File

@ -28,7 +28,7 @@ HB_OT_SHAPE_CLOSURE_sources = \
HB_SUBSET_CLI_sources = \
hb-subset.cc \
options.cc \
options-subset.cc \
options.hh \
subset-options.hh \
main-font-text.hh \
$(NULL)

View File

@ -28,7 +28,7 @@
#include <stdio.h>
#include "main-font-text.hh"
#include "hb-subset.h"
#include "subset-options.hh"
// XXX Remove eventually
const unsigned DEFAULT_FONT_SIZE = FONT_SIZE_NONE;
@ -38,6 +38,7 @@ const unsigned SUBPIXEL_BITS = 0;
* Command line interface to the harfbuzz font subsetter.
*/
struct subset_consumer_t : subset_options_t
{
void add_options (option_parser_t *parser)

View File

@ -16,7 +16,6 @@ hb_ot_shape_closure_sources = [
hb_subset_cli_sources = [
'hb-subset.cc',
'options.cc',
'options-subset.cc',
]
util_deps = [freetype_dep, cairo_dep, cairo_ft_dep, glib_dep]

View File

@ -28,7 +28,6 @@
#define OPTIONS_HH
#include "hb.hh"
#include "hb-subset.h"
#include <stdlib.h>
#include <stddef.h>
@ -622,45 +621,6 @@ struct format_options_t
hb_bool_t trace = false;
};
struct subset_options_t
{
subset_options_t ()
: input (hb_subset_input_create_or_fail ())
{}
~subset_options_t ()
{
hb_subset_input_destroy (input);
}
void add_options (option_parser_t *parser);
hb_bool_t* bool_for(hb_subset_flags_t flag)
{
for (unsigned i = 0; i < sizeof(int) * 8; i++)
{
if (1u << i == flag)
return &flags[i];
}
return &flags[sizeof(int) * 8 - 1];
}
hb_subset_input_t * get_input ()
{
hb_subset_flags_t flags_set = HB_SUBSET_FLAGS_DEFAULT;
for (unsigned i = 0; i < sizeof(int) * 8; i++)
{
if (flags[i])
flags_set = (hb_subset_flags_t) (flags_set | (1u << i));
}
hb_subset_input_set_flags (input, flags_set);
return input;
}
unsigned num_iterations = 1;
hb_subset_input_t *input = nullptr;
hb_bool_t flags[sizeof(int) * 8] = {0};
};
/* fallback implementation for scalbn()/scalbnf() for pre-2013 MSVC */
#if defined (_MSC_VER) && (_MSC_VER < 1800)

View File

@ -24,7 +24,50 @@
* Google Author(s): Garret Rieger
*/
#ifndef SUBSET_OPTIONS_HH
#define SUBSET_OPTIONS_HH
#include "options.hh"
#include "hb-subset.h"
struct subset_options_t
{
subset_options_t ()
: input (hb_subset_input_create_or_fail ())
{}
~subset_options_t ()
{
hb_subset_input_destroy (input);
}
void add_options (option_parser_t *parser);
hb_bool_t* bool_for(hb_subset_flags_t flag)
{
for (unsigned i = 0; i < sizeof(int) * 8; i++)
{
if (1u << i == flag)
return &flags[i];
}
return &flags[sizeof(int) * 8 - 1];
}
hb_subset_input_t * get_input ()
{
hb_subset_flags_t flags_set = HB_SUBSET_FLAGS_DEFAULT;
for (unsigned i = 0; i < sizeof(int) * 8; i++)
{
if (flags[i])
flags_set = (hb_subset_flags_t) (flags_set | (1u << i));
}
hb_subset_input_set_flags (input, flags_set);
return input;
}
unsigned num_iterations = 1;
hb_subset_input_t *input = nullptr;
hb_bool_t flags[sizeof(int) * 8] = {0};
};
static gboolean
@ -323,3 +366,5 @@ subset_options_t::add_options (option_parser_t *parser)
"Options subsetting",
this);
}
#endif