diff --git a/util/hb-ot-shape-closure.cc b/util/hb-ot-shape-closure.cc index 9886bdad5..a21754940 100644 --- a/util/hb-ot-shape-closure.cc +++ b/util/hb-ot-shape-closure.cc @@ -26,6 +26,9 @@ #include "main-font-text.hh" +const unsigned DEFAULT_FONT_SIZE = FONT_SIZE_NONE; +const unsigned SUBPIXEL_BITS = 0; + #ifdef HAVE_FREETYPE #include #endif @@ -108,6 +111,6 @@ struct shape_closure_consumer_t int main (int argc, char **argv) { - main_font_text_t driver; + main_font_text_t driver; return driver.main (argc, argv); } diff --git a/util/hb-shape.cc b/util/hb-shape.cc index c8eac5d00..91d4489d2 100644 --- a/util/hb-shape.cc +++ b/util/hb-shape.cc @@ -28,6 +28,9 @@ #include "main-font-text.hh" #include "shape-consumer.hh" +const unsigned DEFAULT_FONT_SIZE = FONT_SIZE_UPEM; +const unsigned SUBPIXEL_BITS = 0; + struct output_buffer_t { void add_options (option_parser_t *parser) @@ -155,7 +158,7 @@ struct output_buffer_t int main (int argc, char **argv) { - using driver_t = main_font_text_t, FONT_SIZE_UPEM, 0>; + using driver_t = main_font_text_t>; if (argc == 2 && !strcmp (argv[1], "--batch")) { diff --git a/util/hb-subset.cc b/util/hb-subset.cc index b88f5c415..7bd8ab1eb 100644 --- a/util/hb-subset.cc +++ b/util/hb-subset.cc @@ -30,6 +30,9 @@ #include "main-font-text.hh" #include "hb-subset.h" +const unsigned DEFAULT_FONT_SIZE = FONT_SIZE_NONE; +const unsigned SUBPIXEL_BITS = 0; + /* * Command line interface to the harfbuzz font subsetter. */ @@ -131,7 +134,7 @@ struct subset_consumer_t int main (int argc, char **argv) { - using driver_t = main_font_text_t; + using driver_t = main_font_text_t; if (argc == 2 && !strcmp (argv[1], "--batch")) { diff --git a/util/hb-view.cc b/util/hb-view.cc index 69a4c9504..8289b6d1b 100644 --- a/util/hb-view.cc +++ b/util/hb-view.cc @@ -29,12 +29,12 @@ #include "shape-consumer.hh" #include "view-cairo.hh" -#define DEFAULT_FONT_SIZE 256 -#define SUBPIXEL_BITS 6 +const unsigned DEFAULT_FONT_SIZE = 256; +const unsigned SUBPIXEL_BITS = 6; int main (int argc, char **argv) { - main_font_text_t, DEFAULT_FONT_SIZE, SUBPIXEL_BITS> driver; + main_font_text_t> driver; return driver.main (argc, argv); } diff --git a/util/main-font-text.hh b/util/main-font-text.hh index 8e012d288..b75fc551b 100644 --- a/util/main-font-text.hh +++ b/util/main-font-text.hh @@ -47,13 +47,9 @@ locale_to_utf8 (char *s) return t; } -template +template struct main_font_text_t { - main_font_text_t () - : font_opts (default_font_size, subpixel_bits) - {} - void add_options (option_parser_t *parser) { font_opts.add_options (parser); diff --git a/util/options.cc b/util/options.cc index 14f04b8f1..9e6548e13 100644 --- a/util/options.cc +++ b/util/options.cc @@ -547,11 +547,11 @@ font_options_t::add_options (option_parser_t *parser) } char *font_size_text; - if (default_font_size == FONT_SIZE_UPEM) + if (DEFAULT_FONT_SIZE == FONT_SIZE_UPEM) font_size_text = (char *) "Font size (default: upem)"; else { - font_size_text = g_strdup_printf ("Font size (default: %d)", default_font_size); + font_size_text = g_strdup_printf ("Font size (default: %d)", DEFAULT_FONT_SIZE); parser->free_later (font_size_text); } @@ -559,7 +559,7 @@ font_options_t::add_options (option_parser_t *parser) { {"font-file", 0, 0, G_OPTION_ARG_STRING, &this->font_file, "Set font file-name", "filename"}, {"face-index", 0, 0, G_OPTION_ARG_INT, &this->face_index, "Set face index (default: 0)", "index"}, - {"font-size", 0, default_font_size ? 0 : G_OPTION_FLAG_HIDDEN, + {"font-size", 0, DEFAULT_FONT_SIZE ? 0 : G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_CALLBACK, (gpointer) &parse_font_size, font_size_text, "1/2 integers or 'upem'"}, {"font-ppem", 0, 0, G_OPTION_ARG_CALLBACK, (gpointer) &parse_font_ppem, "Set x,y pixels per EM (default: 0; disabled)", "1/2 integers"}, {"font-ptem", 0, 0, G_OPTION_ARG_DOUBLE, &this->ptem, "Set font point-size (default: 0; disabled)", "point-size"}, diff --git a/util/options.hh b/util/options.hh index 5bf9224de..c91028a95 100644 --- a/util/options.hh +++ b/util/options.hh @@ -130,6 +130,9 @@ struct option_parser_t #define FONT_SIZE_UPEM 0x7FFFFFFF #define FONT_SIZE_NONE 0 +extern const unsigned DEFAULT_FONT_SIZE; +extern const unsigned SUBPIXEL_BITS; + struct view_options_t { ~view_options_t () @@ -440,13 +443,6 @@ struct shape_options_t struct font_options_t { - font_options_t (int default_font_size_, - unsigned int subpixel_bits_) - : default_font_size (default_font_size_), - subpixel_bits (subpixel_bits_), - font_size_x (default_font_size_), - font_size_y (default_font_size_) - {} ~font_options_t () { g_free (font_file); @@ -464,13 +460,12 @@ struct font_options_t unsigned face_index = 0; hb_variation_t *variations = nullptr; unsigned int num_variations = 0; - int default_font_size = FONT_SIZE_UPEM; int x_ppem = 0; int y_ppem = 0; double ptem = 0.; - unsigned int subpixel_bits = 0; - mutable double font_size_x = FONT_SIZE_UPEM; - mutable double font_size_y = FONT_SIZE_UPEM; + unsigned int subpixel_bits = SUBPIXEL_BITS; + mutable double font_size_x = DEFAULT_FONT_SIZE; + mutable double font_size_y = DEFAULT_FONT_SIZE; char *font_funcs = nullptr; int ft_load_flags = 2;