提交 6bad092a 编写于 作者: B Behdad Esfahbod

[util] Default to "text" output format in hb-shape

If you say:

  hb-shape font.ttf text --output-file out.txt

This was previously failing:

  Unknown output format `txt'; supported formats are: TEXT / JSON

Now we simply fallback to TEXT if no explicit format was requested.
上级 8b217f5a
...@@ -47,9 +47,14 @@ struct output_buffer_t ...@@ -47,9 +47,14 @@ struct output_buffer_t
output_format = hb_buffer_serialize_format_from_string (options.output_format, -1); output_format = hb_buffer_serialize_format_from_string (options.output_format, -1);
if (!hb_buffer_serialize_format_to_string (output_format)) if (!hb_buffer_serialize_format_to_string (output_format))
{ {
fail (false, "Unknown output format `%s'; supported formats are: %s", if (options.explicit_output_format)
options.output_format, fail (false, "Unknown output format `%s'; supported formats are: %s",
g_strjoinv (" / ", (gchar**) hb_buffer_serialize_list_formats ())); options.output_format,
g_strjoinv (" / ", (gchar**) hb_buffer_serialize_list_formats ()));
else
/* Just default to TEXT if not explicitly requested and the
* file extension is not recognized. */
output_format = HB_BUFFER_SERIALIZE_FORMAT_TEXT;
} }
unsigned int flags = HB_BUFFER_SERIALIZE_FLAGS_DEFAULT; unsigned int flags = HB_BUFFER_SERIALIZE_FLAGS_DEFAULT;
......
...@@ -313,6 +313,7 @@ struct output_options_t : option_group_t ...@@ -313,6 +313,7 @@ struct output_options_t : option_group_t
output_options_t (option_parser_t *parser) { output_options_t (option_parser_t *parser) {
output_file = NULL; output_file = NULL;
output_format = NULL; output_format = NULL;
explicit_output_format = false;
fp = NULL; fp = NULL;
...@@ -327,6 +328,9 @@ struct output_options_t : option_group_t ...@@ -327,6 +328,9 @@ struct output_options_t : option_group_t
void post_parse (GError **error G_GNUC_UNUSED) void post_parse (GError **error G_GNUC_UNUSED)
{ {
if (output_format)
explicit_output_format = true;
if (output_file && !output_format) { if (output_file && !output_format) {
output_format = strrchr (output_file, '.'); output_format = strrchr (output_file, '.');
if (output_format) if (output_format)
...@@ -341,6 +345,7 @@ struct output_options_t : option_group_t ...@@ -341,6 +345,7 @@ struct output_options_t : option_group_t
const char *output_file; const char *output_file;
const char *output_format; const char *output_format;
bool explicit_output_format;
mutable FILE *fp; mutable FILE *fp;
}; };
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册