[HarfBuzz] harfbuzz: Branch 'master' - 3 commits
Behdad Esfahbod
behdad at kemper.freedesktop.org
Sun Sep 3 23:53:42 UTC 2017
test/shaping/hb_test_tools.py | 2 -
test/shaping/run-tests.sh | 4 +-
util/options.cc | 65 +++++++++++++++++++++++++++++++++++++++++-
3 files changed, 67 insertions(+), 4 deletions(-)
New commits:
commit 03a5a6f873e5a50011f1c2418f5ceab86d9c2931
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Fri Sep 1 19:09:54 2017 -0700
[util] Add --unicodes to hb-view / hb-shape
Fixes https://github.com/behdad/harfbuzz/issues/154
diff --git a/test/shaping/hb_test_tools.py b/test/shaping/hb_test_tools.py
index 052974de..b9cb836a 100644
--- a/test/shaping/hb_test_tools.py
+++ b/test/shaping/hb_test_tools.py
@@ -461,7 +461,7 @@ class Unicode:
@staticmethod
def parse (s):
s = re.sub (r"0[xX]", " ", s)
- s = re.sub (r"[<+>{},;&#\\xXuUnNiI\n ]", " ", s)
+ s = re.sub (r"[<+>{},;&#\\xXuUnNiI\n\t]", " ", s)
return [int (x, 16) for x in s.split ()]
@staticmethod
diff --git a/util/options.cc b/util/options.cc
index b1a83edc..1abafdaa 100644
--- a/util/options.cc
+++ b/util/options.cc
@@ -299,6 +299,68 @@ parse_variations (const char *name G_GNUC_UNUSED,
return true;
}
+static gboolean
+parse_text (const char *name G_GNUC_UNUSED,
+ const char *arg,
+ gpointer data,
+ GError **error G_GNUC_UNUSED)
+{
+ text_options_t *text_opts = (text_options_t *) data;
+
+ if (text_opts->text)
+ {
+ g_set_error (error, G_OPTION_ERROR, G_OPTION_ERROR_BAD_VALUE,
+ "Either --text or --unicodes can be provided but not both");
+ return false;
+ }
+
+ text_opts->text = g_strdup (arg);
+ return true;
+}
+
+
+static gboolean
+parse_unicodes (const char *name G_GNUC_UNUSED,
+ const char *arg,
+ gpointer data,
+ GError **error G_GNUC_UNUSED)
+{
+ text_options_t *text_opts = (text_options_t *) data;
+
+ if (text_opts->text)
+ {
+ g_set_error (error, G_OPTION_ERROR, G_OPTION_ERROR_BAD_VALUE,
+ "Either --text or --unicodes can be provided but not both");
+ return false;
+ }
+
+ GString *gs = g_string_new (NULL);
+ char *s = (char *) arg;
+ char *p;
+
+ while (s && *s)
+ {
+ while (*s && strchr ("<+>{},;&#\\xXuUnNiI\n\t", *s))
+ s++;
+
+ errno = 0;
+ hb_codepoint_t u = strtoul (s, &p, 16);
+ if (errno || s == p)
+ {
+ g_set_error (error, G_OPTION_ERROR, G_OPTION_ERROR_BAD_VALUE,
+ "Failed parsing Unicode values at: '%s'", s);
+ return false;
+ }
+
+ g_string_append_unichar (gs, u);
+
+ s = p;
+ }
+
+ text_opts->text = g_string_free (gs, FALSE);
+ return true;
+}
+
void
view_options_t::add_options (option_parser_t *parser)
@@ -491,8 +553,9 @@ text_options_t::add_options (option_parser_t *parser)
{
GOptionEntry entries[] =
{
- {"text", 0, 0, G_OPTION_ARG_STRING, &this->text, "Set input text", "string"},
+ {"text", 0, 0, G_OPTION_ARG_CALLBACK, (gpointer) &parse_text, "Set input text", "string"},
{"text-file", 0, 0, G_OPTION_ARG_STRING, &this->text_file, "Set input text file-name\n\n If no text is provided, standard input is used for input.\n", "filename"},
+ {"unicodes", 0, 0, G_OPTION_ARG_CALLBACK, (gpointer) &parse_unicodes, "Set input Unicode codepoints", "list of hex numbers"},
{"text-before", 0, 0, G_OPTION_ARG_STRING, &this->text_before, "Set text context before each line", "string"},
{"text-after", 0, 0, G_OPTION_ARG_STRING, &this->text_after, "Set text context after each line", "string"},
{NULL}
commit 0e5b475d98dd67e927534508fe2cd8dc9765e24e
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Fri Sep 1 18:28:47 2017 -0700
Minor
diff --git a/test/shaping/run-tests.sh b/test/shaping/run-tests.sh
index 9f365450..c6b35e31 100755
--- a/test/shaping/run-tests.sh
+++ b/test/shaping/run-tests.sh
@@ -23,7 +23,7 @@ for f in "$@"; do
$reference || echo "Running tests in $f"
while IFS=: read fontfile options unicodes glyphs_expected; do
if echo "$fontfile" | grep -q '^#'; then
- $reference || echo "#hb-shape $fontfile --unicodes $unicodes"
+ $reference || echo "# hb-shape $fontfile --unicodes $unicodes"
continue
fi
$reference || echo "hb-shape $fontfile --unicodes $unicodes"
commit 3e1fc6d18ba0019bbeede78b95070a6e7156c314
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Fri Sep 1 10:46:48 2017 -0700
Minor
diff --git a/test/shaping/run-tests.sh b/test/shaping/run-tests.sh
index 2b10e7c8..9f365450 100755
--- a/test/shaping/run-tests.sh
+++ b/test/shaping/run-tests.sh
@@ -23,10 +23,10 @@ for f in "$@"; do
$reference || echo "Running tests in $f"
while IFS=: read fontfile options unicodes glyphs_expected; do
if echo "$fontfile" | grep -q '^#'; then
- $reference || echo "Skipping $fontfile:$unicodes"
+ $reference || echo "#hb-shape $fontfile --unicodes $unicodes"
continue
fi
- $reference || echo "Testing $fontfile:$unicodes"
+ $reference || echo "hb-shape $fontfile --unicodes $unicodes"
glyphs=`$srcdir/hb-unicode-encode "$unicodes" | $hb_shape $options "$srcdir/$fontfile"`
if test $? != 0; then
echo "hb-shape failed." >&2
More information about the HarfBuzz
mailing list