From 11e51993ab562d4c7460eb7c43d0e97404e628e7 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Mon, 19 Sep 2011 09:58:55 -0400 Subject: [PATCH] [util] Move font-size into view-options --- util/options.cc | 2 +- util/options.hh | 7 +++---- util/view-cairo.cc | 4 ++-- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/util/options.cc b/util/options.cc index fe2feaf..96d131f 100644 --- a/util/options.cc +++ b/util/options.cc @@ -336,6 +336,7 @@ view_options_t::add_options (option_parser_t *parser) {"foreground", 0, 0, G_OPTION_ARG_STRING, &this->fore, "Set foreground color (default: "DEFAULT_FORE")", "red/#rrggbb/#rrggbbaa"}, {"line-space", 0, 0, G_OPTION_ARG_DOUBLE, &this->line_space, "Set space between lines (default: 0)", "units"}, {"margin", 0, 0, G_OPTION_ARG_CALLBACK, (gpointer) &parse_margin, "Margin around output (default: "G_STRINGIFY(DEFAULT_MARGIN)")","one to four numbers"}, + {"font-size", 0, 0, G_OPTION_ARG_DOUBLE, &this->font_size, "Font size (default: "G_STRINGIFY(DEFAULT_FONT_SIZE)")","size"}, {NULL} }; parser->add_group (entries, @@ -371,7 +372,6 @@ font_options_t::add_options (option_parser_t *parser) { {"font-file", 0, 0, G_OPTION_ARG_STRING, &this->font_file, "Font file-name", "filename"}, {"face-index", 0, 0, G_OPTION_ARG_INT, &this->face_index, "Face index (default: 0)", "index"}, - {"font-size", 0, 0, G_OPTION_ARG_DOUBLE, &this->font_size, "Font size (default: "G_STRINGIFY(DEFAULT_FONT_SIZE)")","size"}, {NULL} }; parser->add_group (entries, diff --git a/util/options.hh b/util/options.hh index a101f7d..e8747a6 100644 --- a/util/options.hh +++ b/util/options.hh @@ -77,6 +77,7 @@ struct option_parser_t #define DEFAULT_MARGIN 18 #define DEFAULT_FORE "#000000" #define DEFAULT_BACK "#FFFFFF" +#define DEFAULT_FONT_SIZE 36 struct view_options_t : option_group_t { @@ -86,6 +87,7 @@ struct view_options_t : option_group_t back = DEFAULT_BACK; line_space = 0; margin.t = margin.r = margin.b = margin.l = DEFAULT_MARGIN; + font_size = DEFAULT_FONT_SIZE; add_options (parser); } @@ -99,6 +101,7 @@ struct view_options_t : option_group_t struct margin_t { double t, r, b, l; } margin; + double font_size; }; @@ -142,14 +145,11 @@ struct shape_options_t : option_group_t }; -#define DEFAULT_FONT_SIZE 36 - struct font_options_t : option_group_t { font_options_t (option_parser_t *parser) { font_file = NULL; face_index = 0; - font_size = DEFAULT_FONT_SIZE; font = NULL; @@ -165,7 +165,6 @@ struct font_options_t : option_group_t const char *font_file; int face_index; - double font_size; private: mutable hb_font_t *font; diff --git a/util/view-cairo.cc b/util/view-cairo.cc index 9ca44c8..c6278f1 100644 --- a/util/view-cairo.cc +++ b/util/view-cairo.cc @@ -80,7 +80,7 @@ void view_cairo_t::init (const font_options_t *font_opts) { lines = g_array_new (FALSE, FALSE, sizeof (line_t)); - scale = double (font_opts->font_size) / hb_face_get_upem (hb_font_get_face (font_opts->get_font ())); + scale = double (font_size) / hb_face_get_upem (hb_font_get_face (font_opts->get_font ())); } void @@ -217,7 +217,7 @@ view_cairo_t::create_scaled_font (const font_options_t *font_opts) cairo_matrix_init_identity (&ctm); cairo_matrix_init_scale (&font_matrix, - font_opts->font_size, font_opts->font_size); + font_size, font_size); font_options = cairo_font_options_create (); cairo_font_options_set_hint_style (font_options, CAIRO_HINT_STYLE_NONE); cairo_font_options_set_hint_metrics (font_options, CAIRO_HINT_METRICS_OFF); -- 2.7.4