[util] Move font-size into view-options
This commit is contained in:
parent
0fe2960197
commit
11e51993ab
|
@ -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"},
|
{"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"},
|
{"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"},
|
{"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}
|
{NULL}
|
||||||
};
|
};
|
||||||
parser->add_group (entries,
|
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"},
|
{"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"},
|
{"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}
|
{NULL}
|
||||||
};
|
};
|
||||||
parser->add_group (entries,
|
parser->add_group (entries,
|
||||||
|
|
|
@ -77,6 +77,7 @@ struct option_parser_t
|
||||||
#define DEFAULT_MARGIN 18
|
#define DEFAULT_MARGIN 18
|
||||||
#define DEFAULT_FORE "#000000"
|
#define DEFAULT_FORE "#000000"
|
||||||
#define DEFAULT_BACK "#FFFFFF"
|
#define DEFAULT_BACK "#FFFFFF"
|
||||||
|
#define DEFAULT_FONT_SIZE 36
|
||||||
|
|
||||||
struct view_options_t : option_group_t
|
struct view_options_t : option_group_t
|
||||||
{
|
{
|
||||||
|
@ -86,6 +87,7 @@ struct view_options_t : option_group_t
|
||||||
back = DEFAULT_BACK;
|
back = DEFAULT_BACK;
|
||||||
line_space = 0;
|
line_space = 0;
|
||||||
margin.t = margin.r = margin.b = margin.l = DEFAULT_MARGIN;
|
margin.t = margin.r = margin.b = margin.l = DEFAULT_MARGIN;
|
||||||
|
font_size = DEFAULT_FONT_SIZE;
|
||||||
|
|
||||||
add_options (parser);
|
add_options (parser);
|
||||||
}
|
}
|
||||||
|
@ -99,6 +101,7 @@ struct view_options_t : option_group_t
|
||||||
struct margin_t {
|
struct margin_t {
|
||||||
double t, r, b, l;
|
double t, r, b, l;
|
||||||
} margin;
|
} 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
|
struct font_options_t : option_group_t
|
||||||
{
|
{
|
||||||
font_options_t (option_parser_t *parser) {
|
font_options_t (option_parser_t *parser) {
|
||||||
font_file = NULL;
|
font_file = NULL;
|
||||||
face_index = 0;
|
face_index = 0;
|
||||||
font_size = DEFAULT_FONT_SIZE;
|
|
||||||
|
|
||||||
font = NULL;
|
font = NULL;
|
||||||
|
|
||||||
|
@ -165,7 +165,6 @@ struct font_options_t : option_group_t
|
||||||
|
|
||||||
const char *font_file;
|
const char *font_file;
|
||||||
int face_index;
|
int face_index;
|
||||||
double font_size;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
mutable hb_font_t *font;
|
mutable hb_font_t *font;
|
||||||
|
|
|
@ -80,7 +80,7 @@ void
|
||||||
view_cairo_t::init (const font_options_t *font_opts)
|
view_cairo_t::init (const font_options_t *font_opts)
|
||||||
{
|
{
|
||||||
lines = g_array_new (FALSE, FALSE, sizeof (line_t));
|
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
|
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_identity (&ctm);
|
||||||
cairo_matrix_init_scale (&font_matrix,
|
cairo_matrix_init_scale (&font_matrix,
|
||||||
font_opts->font_size, font_opts->font_size);
|
font_size, font_size);
|
||||||
font_options = cairo_font_options_create ();
|
font_options = cairo_font_options_create ();
|
||||||
cairo_font_options_set_hint_style (font_options, CAIRO_HINT_STYLE_NONE);
|
cairo_font_options_set_hint_style (font_options, CAIRO_HINT_STYLE_NONE);
|
||||||
cairo_font_options_set_hint_metrics (font_options, CAIRO_HINT_METRICS_OFF);
|
cairo_font_options_set_hint_metrics (font_options, CAIRO_HINT_METRICS_OFF);
|
||||||
|
|
Loading…
Reference in New Issue