X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=util%2Foptions.cc;h=43ff90ad10345974cca9a831d19b6256bf269017;hb=a280f8312cc9b27515efbab292b95b9d147a2b73;hp=c5a4f0f0b14e0eb16c4f5909efe34d00917e65b1;hpb=610626019cd10944b76622e30b2610910bf4b2b8;p=platform%2Fupstream%2Fharfbuzz.git diff --git a/util/options.cc b/util/options.cc index c5a4f0f..43ff90a 100644 --- a/util/options.cc +++ b/util/options.cc @@ -31,6 +31,8 @@ #endif #include +#define DELIMITERS "<+>{},;&#\\xXuUnNiI\n\t\v\f\r " + static struct supported_font_funcs_t { char name[4]; void (*func) (hb_font_t *); @@ -194,8 +196,8 @@ parse_shapers (const char *name G_GNUC_UNUSED, bool found = false; for (const char **hb_shaper = hb_shape_list_shapers (); *hb_shaper; hb_shaper++) { if (strcmp (*shaper, *hb_shaper) == 0) { - found = true; - break; + found = true; + break; } } if (!found) { @@ -226,9 +228,9 @@ list_shapers (const char *name G_GNUC_UNUSED, static gboolean parse_features (const char *name G_GNUC_UNUSED, - const char *arg, - gpointer data, - GError **error G_GNUC_UNUSED) + const char *arg, + gpointer data, + GError **error G_GNUC_UNUSED) { shape_options_t *shape_opts = (shape_options_t *) data; char *s = (char *) arg; @@ -269,9 +271,9 @@ parse_features (const char *name G_GNUC_UNUSED, static gboolean parse_variations (const char *name G_GNUC_UNUSED, - const char *arg, - gpointer data, - GError **error G_GNUC_UNUSED) + const char *arg, + gpointer data, + GError **error G_GNUC_UNUSED) { font_options_t *font_opts = (font_options_t *) data; char *s = (char *) arg; @@ -333,9 +335,9 @@ parse_text (const char *name G_GNUC_UNUSED, static gboolean parse_unicodes (const char *name G_GNUC_UNUSED, - const char *arg, - gpointer data, - GError **error G_GNUC_UNUSED) + const char *arg, + gpointer data, + GError **error G_GNUC_UNUSED) { text_options_t *text_opts = (text_options_t *) data; @@ -347,28 +349,37 @@ parse_unicodes (const char *name G_GNUC_UNUSED, } GString *gs = g_string_new (nullptr); - char *s = (char *) arg; - char *p; - - while (s && *s) + if (0 == strcmp (arg, "*")) + { + g_string_append_c (gs, '*'); + } + else { - while (*s && strchr ("<+>{},;&#\\xXuUnNiI\n\t\v\f\r ", *s)) - s++; - if (!*s) - break; - errno = 0; - hb_codepoint_t u = strtoul (s, &p, 16); - if (errno || s == p) + char *s = (char *) arg; + char *p; + + while (s && *s) { - g_set_error (error, G_OPTION_ERROR, G_OPTION_ERROR_BAD_VALUE, - "Failed parsing Unicode values at: '%s'", s); - return false; - } + while (*s && strchr (DELIMITERS, *s)) + s++; + if (!*s) + break; - g_string_append_unichar (gs, u); + errno = 0; + hb_codepoint_t u = strtoul (s, &p, 16); + if (errno || s == p) + { + g_string_free (gs, TRUE); + g_set_error (error, G_OPTION_ERROR, G_OPTION_ERROR_BAD_VALUE, + "Failed parsing Unicode values at: '%s'", s); + return false; + } - s = p; + g_string_append_unichar (gs, u); + + s = p; + } } text_opts->text_len = gs->len; @@ -705,7 +716,7 @@ font_options_t::get_font () const GString *s = g_string_new (nullptr); for (unsigned int i = 0; i < ARRAY_LENGTH (supported_font_funcs); i++) { - if (i) + if (i) g_string_append_c (s, '/'); g_string_append (s, supported_font_funcs[i].name); } @@ -866,9 +877,9 @@ format_options_t::add_options (option_parser_t *parser) parser->add_group (entries, "output-syntax", "Output syntax:\n" - " text: [=@,+,|...]\n" - " json: [{\"g\": , \"ax\": , \"ay\": , \"dx\": , \"dy\": , \"cl\": }, ...]\n" - "\nOutput syntax options:", + " text: [=@,+,|...]\n" + " json: [{\"g\": , \"ax\": , \"ay\": , \"dx\": , \"dy\": , \"cl\": }, ...]\n" + "\nOutput syntax options:", "Options for the syntax of the output", this); } @@ -970,22 +981,3 @@ format_options_t::serialize_buffer_of_glyphs (hb_buffer_t *buffer, serialize_glyphs (buffer, font, output_format, format_flags, gs); g_string_append_c (gs, '\n'); } - -void -subset_options_t::add_options (option_parser_t *parser) -{ - GOptionEntry entries[] = - { - {"layout", 0, 0, G_OPTION_ARG_NONE, &this->keep_layout, "Keep OpenType Layout tables", nullptr}, - {"no-hinting", 0, 0, G_OPTION_ARG_NONE, &this->drop_hints, "Whether to drop hints", nullptr}, - {"retain-gids", 0, 0, G_OPTION_ARG_NONE, &this->retain_gids, "If set don't renumber glyph ids in the subset.", nullptr}, - {"desubroutinize", 0, 0, G_OPTION_ARG_NONE, &this->desubroutinize, "Remove CFF/CFF2 use of subroutines", nullptr}, - - {nullptr} - }; - parser->add_group (entries, - "subset", - "Subset options:", - "Options subsetting", - this); -}