diff options
Diffstat (limited to 'util/options.hh')
-rw-r--r-- | util/options.hh | 78 |
1 files changed, 60 insertions, 18 deletions
diff --git a/util/options.hh b/util/options.hh index 8b9b10e..919e4f8 100644 --- a/util/options.hh +++ b/util/options.hh @@ -150,19 +150,24 @@ struct view_options_t : option_group_t { view_options_t (option_parser_t *parser) { annotate = false; - fore = DEFAULT_FORE; - back = DEFAULT_BACK; + fore = NULL; + back = NULL; line_space = 0; margin.t = margin.r = margin.b = margin.l = DEFAULT_MARGIN; add_options (parser); } + ~view_options_t (void) + { + g_free (fore); + g_free (back); + } void add_options (option_parser_t *parser); hb_bool_t annotate; - const char *fore; - const char *back; + char *fore; + char *back; double line_space; struct margin_t { double t, r, b, l; @@ -180,6 +185,7 @@ struct shape_options_t : option_group_t num_features = 0; shapers = NULL; utf8_clusters = false; + cluster_level = HB_BUFFER_CLUSTER_LEVEL_DEFAULT; normalize_glyphs = false; num_iterations = 1; @@ -187,6 +193,9 @@ struct shape_options_t : option_group_t } ~shape_options_t (void) { + g_free (direction); + g_free (language); + g_free (script); free (features); g_strfreev (shapers); } @@ -202,6 +211,7 @@ struct shape_options_t : option_group_t (bot ? HB_BUFFER_FLAG_BOT : 0) | (eot ? HB_BUFFER_FLAG_EOT : 0) | (preserve_default_ignorables ? HB_BUFFER_FLAG_PRESERVE_DEFAULT_IGNORABLES : 0))); + hb_buffer_set_cluster_level (buffer, cluster_level); hb_buffer_guess_segment_properties (buffer); } @@ -252,9 +262,9 @@ struct shape_options_t : option_group_t } /* Buffer properties */ - const char *direction; - const char *language; - const char *script; + char *direction; + char *language; + char *script; /* Buffer flags */ hb_bool_t bot; @@ -265,6 +275,7 @@ struct shape_options_t : option_group_t unsigned int num_features; char **shapers; hb_bool_t utf8_clusters; + hb_buffer_cluster_level_t cluster_level; hb_bool_t normalize_glyphs; unsigned int num_iterations; }; @@ -287,6 +298,8 @@ struct font_options_t : option_group_t add_options (parser); } ~font_options_t (void) { + g_free (font_file); + g_free (font_funcs); hb_font_destroy (font); } @@ -294,13 +307,13 @@ struct font_options_t : option_group_t hb_font_t *get_font (void) const; - const char *font_file; + char *font_file; int face_index; int default_font_size; unsigned int subpixel_bits; mutable double font_size_x; mutable double font_size_y; - const char *font_funcs; + char *font_funcs; private: mutable hb_font_t *font; @@ -318,11 +331,16 @@ struct text_options_t : option_group_t fp = NULL; gs = NULL; - text_len = (unsigned int) -1; + line = NULL; + line_len = (unsigned int) -1; add_options (parser); } ~text_options_t (void) { + g_free (text_before); + g_free (text_after); + g_free (text); + g_free (text_file); if (gs) g_string_free (gs, true); if (fp) @@ -336,21 +354,21 @@ struct text_options_t : option_group_t g_set_error (error, G_OPTION_ERROR, G_OPTION_ERROR_BAD_VALUE, "Only one of text and text-file can be set"); - }; const char *get_line (unsigned int *len); - const char *text_before; - const char *text_after; + char *text_before; + char *text_after; - const char *text; - const char *text_file; + char *text; + char *text_file; private: FILE *fp; GString *gs; - unsigned int text_len; + char *line; + unsigned int line_len; }; struct output_options_t : option_group_t @@ -367,6 +385,8 @@ struct output_options_t : option_group_t add_options (parser); } ~output_options_t (void) { + g_free (output_file); + g_free (output_format); if (fp) fclose (fp); } @@ -381,7 +401,10 @@ struct output_options_t : option_group_t if (output_file && !output_format) { output_format = strrchr (output_file, '.'); if (output_format) + { output_format++; /* skip the dot */ + output_format = strdup (output_format); + } } if (output_file && 0 == strcmp (output_file, "-")) @@ -390,8 +413,8 @@ struct output_options_t : option_group_t FILE *get_file_handle (void); - const char *output_file; - const char *output_format; + char *output_file; + char *output_format; const char **supported_formats; bool explicit_output_format; @@ -407,6 +430,7 @@ struct format_options_t : option_group_t show_text = false; show_unicode = false; show_line_num = false; + show_extents = false; add_options (parser); } @@ -447,7 +471,25 @@ struct format_options_t : option_group_t hb_bool_t show_text; hb_bool_t show_unicode; hb_bool_t show_line_num; + hb_bool_t show_extents; }; +/* fallback implementation for scalbn()/scalbnf() for pre-2013 MSVC */ +#if defined (_MSC_VER) && (_MSC_VER < 1800) + +#ifndef FLT_RADIX +#define FLT_RADIX 2 +#endif + +__inline long double scalbn (long double x, int exp) +{ + return x * (pow ((long double) FLT_RADIX, exp)); +} + +__inline float scalbnf (float x, int exp) +{ + return x * (pow ((float) FLT_RADIX, exp)); +} +#endif #endif |