summaryrefslogtreecommitdiff
path: root/util/options.hh
diff options
context:
space:
mode:
Diffstat (limited to 'util/options.hh')
-rw-r--r--util/options.hh72
1 files changed, 48 insertions, 24 deletions
diff --git a/util/options.hh b/util/options.hh
index 8dfc842..e846258 100644
--- a/util/options.hh
+++ b/util/options.hh
@@ -27,7 +27,7 @@
#ifndef OPTIONS_HH
#define OPTIONS_HH
-#include "hb-private.hh"
+#include "hb.hh"
#include <stdlib.h>
#include <stddef.h>
@@ -46,9 +46,7 @@
#endif
#include <hb.h>
-#ifdef HAVE_OT
#include <hb-ot.h>
-#endif
#include <glib.h>
#include <glib/gprintf.h>
@@ -56,16 +54,19 @@ void fail (hb_bool_t suggest_help, const char *format, ...) G_GNUC_NORETURN G_GN
struct option_group_t
{
+ virtual ~option_group_t () {}
+
virtual void add_options (struct option_parser_t *parser) = 0;
- virtual void pre_parse (GError **error G_GNUC_UNUSED) {};
- virtual void post_parse (GError **error G_GNUC_UNUSED) {};
+ virtual void pre_parse (GError **error G_GNUC_UNUSED) {}
+ virtual void post_parse (GError **error G_GNUC_UNUSED) {}
};
struct option_parser_t
{
- option_parser_t (const char *usage) {
+ option_parser_t (const char *usage)
+ {
memset (this, 0, sizeof (*this));
usage_str = usage;
context = g_option_context_new (usage);
@@ -73,13 +74,17 @@ struct option_parser_t
add_main_options ();
}
- ~option_parser_t (void) {
+
+ static void _g_free_g_func (void *p, void * G_GNUC_UNUSED) { g_free (p); }
+
+ ~option_parser_t ()
+ {
g_option_context_free (context);
- g_ptr_array_foreach (to_free, (GFunc) g_free, nullptr);
+ g_ptr_array_foreach (to_free, _g_free_g_func, nullptr);
g_ptr_array_free (to_free, TRUE);
}
- void add_main_options (void);
+ void add_main_options ();
void add_group (GOptionEntry *entries,
const gchar *name,
@@ -93,7 +98,7 @@ struct option_parser_t
void parse (int *argc, char ***argv);
- G_GNUC_NORETURN void usage (void) {
+ G_GNUC_NORETURN void usage () {
g_printerr ("Usage: %s [OPTION...] %s\n", g_get_prgname (), usage_str);
exit (1);
}
@@ -113,7 +118,8 @@ struct option_parser_t
struct view_options_t : option_group_t
{
- view_options_t (option_parser_t *parser) {
+ view_options_t (option_parser_t *parser)
+ {
annotate = false;
fore = nullptr;
back = nullptr;
@@ -122,7 +128,7 @@ struct view_options_t : option_group_t
add_options (parser);
}
- ~view_options_t (void)
+ virtual ~view_options_t ()
{
g_free (fore);
g_free (back);
@@ -150,6 +156,7 @@ struct shape_options_t : option_group_t
num_features = 0;
shapers = nullptr;
utf8_clusters = false;
+ invisible_glyph = 0;
cluster_level = HB_BUFFER_CLUSTER_LEVEL_DEFAULT;
normalize_glyphs = false;
verify = false;
@@ -157,7 +164,7 @@ struct shape_options_t : option_group_t
add_options (parser);
}
- ~shape_options_t (void)
+ virtual ~shape_options_t ()
{
g_free (direction);
g_free (language);
@@ -180,6 +187,7 @@ struct shape_options_t : option_group_t
(preserve_default_ignorables ? HB_BUFFER_FLAG_PRESERVE_DEFAULT_IGNORABLES : 0) |
(remove_default_ignorables ? HB_BUFFER_FLAG_REMOVE_DEFAULT_IGNORABLES : 0) |
0));
+ hb_buffer_set_invisible_glyph (buffer, invisible_glyph);
hb_buffer_set_cluster_level (buffer, cluster_level);
hb_buffer_guess_segment_properties (buffer);
}
@@ -430,6 +438,7 @@ struct shape_options_t : option_group_t
unsigned int num_features;
char **shapers;
hb_bool_t utf8_clusters;
+ hb_codepoint_t invisible_glyph;
hb_buffer_cluster_level_t cluster_level;
hb_bool_t normalize_glyphs;
hb_bool_t verify;
@@ -454,12 +463,15 @@ struct font_options_t : option_group_t
face_index = 0;
font_size_x = font_size_y = default_font_size;
font_funcs = nullptr;
+ ft_load_flags = 2;
+ blob = nullptr;
font = nullptr;
add_options (parser);
}
- ~font_options_t (void) {
+ virtual ~font_options_t ()
+ {
g_free (font_file);
free (variations);
g_free (font_funcs);
@@ -468,9 +480,10 @@ struct font_options_t : option_group_t
void add_options (option_parser_t *parser);
- hb_font_t *get_font (void) const;
+ hb_font_t *get_font () const;
char *font_file;
+ mutable hb_blob_t *blob;
int face_index;
hb_variation_t *variations;
unsigned int num_variations;
@@ -482,6 +495,7 @@ struct font_options_t : option_group_t
mutable double font_size_x;
mutable double font_size_y;
char *font_funcs;
+ int ft_load_flags;
private:
mutable hb_font_t *font;
@@ -490,10 +504,12 @@ struct font_options_t : option_group_t
struct text_options_t : option_group_t
{
- text_options_t (option_parser_t *parser) {
+ text_options_t (option_parser_t *parser)
+ {
text_before = nullptr;
text_after = nullptr;
+ text_len = -1;
text = nullptr;
text_file = nullptr;
@@ -504,14 +520,15 @@ struct text_options_t : option_group_t
add_options (parser);
}
- ~text_options_t (void) {
+ virtual ~text_options_t ()
+ {
g_free (text_before);
g_free (text_after);
g_free (text);
g_free (text_file);
if (gs)
g_string_free (gs, true);
- if (fp)
+ if (fp && fp != stdin)
fclose (fp);
}
@@ -522,13 +539,14 @@ 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);
char *text_before;
char *text_after;
+ int text_len;
char *text;
char *text_file;
@@ -542,7 +560,8 @@ struct text_options_t : option_group_t
struct output_options_t : option_group_t
{
output_options_t (option_parser_t *parser,
- const char **supported_formats_ = nullptr) {
+ const char **supported_formats_ = nullptr)
+ {
output_file = nullptr;
output_format = nullptr;
supported_formats = supported_formats_;
@@ -552,10 +571,11 @@ struct output_options_t : option_group_t
add_options (parser);
}
- ~output_options_t (void) {
+ virtual ~output_options_t ()
+ {
g_free (output_file);
g_free (output_format);
- if (fp)
+ if (fp && fp != stdout)
fclose (fp);
}
@@ -571,7 +591,7 @@ struct output_options_t : option_group_t
if (output_format)
{
output_format++; /* skip the dot */
- output_format = strdup (output_format);
+ output_format = g_strdup (output_format);
}
}
@@ -579,7 +599,7 @@ struct output_options_t : option_group_t
output_file = nullptr; /* STDOUT */
}
- FILE *get_file_handle (void);
+ FILE *get_file_handle ();
char *output_file;
char *output_format;
@@ -653,14 +673,18 @@ struct subset_options_t : option_group_t
{
subset_options_t (option_parser_t *parser)
{
+ keep_layout = false;
drop_hints = false;
+ desubroutinize = false;
add_options (parser);
}
void add_options (option_parser_t *parser);
+ hb_bool_t keep_layout;
hb_bool_t drop_hints;
+ hb_bool_t desubroutinize;
};
/* fallback implementation for scalbn()/scalbnf() for pre-2013 MSVC */