[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.
This commit is contained in:
parent
8b217f5ac5
commit
6bad092aa8
|
@ -47,9 +47,14 @@ struct output_buffer_t
|
|||
output_format = hb_buffer_serialize_format_from_string (options.output_format, -1);
|
||||
if (!hb_buffer_serialize_format_to_string (output_format))
|
||||
{
|
||||
fail (false, "Unknown output format `%s'; supported formats are: %s",
|
||||
options.output_format,
|
||||
g_strjoinv (" / ", (gchar**) hb_buffer_serialize_list_formats ()));
|
||||
if (options.explicit_output_format)
|
||||
fail (false, "Unknown output format `%s'; supported formats are: %s",
|
||||
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;
|
||||
|
|
|
@ -313,6 +313,7 @@ struct output_options_t : option_group_t
|
|||
output_options_t (option_parser_t *parser) {
|
||||
output_file = NULL;
|
||||
output_format = NULL;
|
||||
explicit_output_format = false;
|
||||
|
||||
fp = NULL;
|
||||
|
||||
|
@ -327,6 +328,9 @@ struct output_options_t : option_group_t
|
|||
|
||||
void post_parse (GError **error G_GNUC_UNUSED)
|
||||
{
|
||||
if (output_format)
|
||||
explicit_output_format = true;
|
||||
|
||||
if (output_file && !output_format) {
|
||||
output_format = strrchr (output_file, '.');
|
||||
if (output_format)
|
||||
|
@ -341,6 +345,7 @@ struct output_options_t : option_group_t
|
|||
|
||||
const char *output_file;
|
||||
const char *output_format;
|
||||
bool explicit_output_format;
|
||||
|
||||
mutable FILE *fp;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue