From 58e20f53bf61244e3eef09be8ebed60aaf52fb11 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Tue, 30 Oct 2018 00:50:18 -0700 Subject: [PATCH] [util] Add hb-shape --batch --- util/hb-shape.cc | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/util/hb-shape.cc b/util/hb-shape.cc index 337cd4319..6c727d019 100644 --- a/util/hb-shape.cc +++ b/util/hb-shape.cc @@ -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, 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, FONT_SIZE_UPEM, 0> driver; return driver.main (argc, argv); }