[util] Add hb-shape --batch

This commit is contained in:
Behdad Esfahbod 2018-10-30 00:50:18 -07:00
parent 6131fb6283
commit 58e20f53bf
1 changed files with 30 additions and 0 deletions

View File

@ -160,6 +160,36 @@ struct output_buffer_t
int
main (int argc, char **argv)
{
if (argc == 2 && !strcmp (argv[1], "--batch"))
{
unsigned int ret = 0;
char *buf = nullptr;
size_t len;
while (getline (&buf, &len, stdin) > 0)
{
size_t l = strlen (buf);
if (l && buf[l - 1] == '\n') buf[l - 1] = '\0';
main_font_text_t<shape_consumer_t<output_buffer_t>, FONT_SIZE_UPEM, 0> driver;
char *args[32];
argc = 0;
char *p = buf, *e;
args[argc++] = p;
while ((e = strchr (p, ' ')) && argc < (int) (int) ARRAY_LENGTH (args))
{
*e++ = '\0';
while (*e == ' ')
e++;
args[argc++] = p = e;
}
ret |= driver.main (argc, args);
fflush (stdout);
if (ret)
break;
}
free (buf);
return ret;
}
main_font_text_t<shape_consumer_t<output_buffer_t>, FONT_SIZE_UPEM, 0> driver;
return driver.main (argc, argv);
}