[HarfBuzz] harfbuzz-ng: Branch 'master' - 4 commits
Behdad Esfahbod
behdad at kemper.freedesktop.org
Thu Jan 19 09:47:23 PST 2012
test/test-shape-complex.c | 16 +++++++++++
util/hb-shape.cc | 7 +++--
util/options.cc | 62 +++++++++++++++++++++++++++++++++++++++++++---
util/options.hh | 27 +++++++++++++++++---
4 files changed, 103 insertions(+), 9 deletions(-)
New commits:
commit cdc673d97c5ffedb386865a81f54a5cedcbad27c
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Thu Jan 19 12:46:18 2012 -0500
[hb-shape] Add --show-line-num
Ok, much more useful as a test suite driver now.
diff --git a/util/hb-shape.cc b/util/hb-shape.cc
index 1910848..a76a778 100644
--- a/util/hb-shape.cc
+++ b/util/hb-shape.cc
@@ -42,7 +42,7 @@ struct output_buffer_t : output_options_t, format_options_t
protected:
GString *gs;
hb_font_t *font;
- hb_buffer_t *scratch;
+ unsigned int line_no;
};
void
@@ -51,7 +51,7 @@ output_buffer_t::init (const font_options_t *font_opts)
get_file_handle ();
font = hb_font_reference (font_opts->get_font ());
gs = g_string_new (NULL);
- scratch = hb_buffer_create ();
+ line_no = 0;
}
void
@@ -59,29 +59,15 @@ output_buffer_t::consume_line (hb_buffer_t *buffer,
const char *text,
unsigned int text_len)
{
+ line_no++;
g_string_set_size (gs, 0);
-
- if (show_text) {
- g_string_append_len (gs, text, text_len);
- g_string_append_c (gs, '\n');
- }
-
- if (show_unicode) {
- hb_buffer_reset (scratch);
- hb_buffer_add_utf8 (scratch, text, text_len, 0, -1);
- serialize_unicode (buffer, gs);
- g_string_append_c (gs, '\n');
- }
-
- serialize_glyphs (buffer, font, gs);
- fprintf (fp, "%s\n", gs->str);
+ serialize_line (buffer, line_no, text, text_len, font, gs);
+ fprintf (fp, "%s", gs->str);
}
void
output_buffer_t::finish (const font_options_t *font_opts)
{
- hb_buffer_destroy (scratch);
- scratch = NULL;
g_string_free (gs, TRUE);
gs = NULL;
hb_font_destroy (font);
diff --git a/util/options.cc b/util/options.cc
index e497d72..2bf2c58 100644
--- a/util/options.cc
+++ b/util/options.cc
@@ -678,6 +678,7 @@ format_options_t::add_options (option_parser_t *parser)
{"no-clusters", 0, G_OPTION_FLAG_REVERSE, G_OPTION_ARG_NONE, &this->show_clusters, "Do not show cluster mapping", NULL},
{"show-text", 0, 0, G_OPTION_ARG_NONE, &this->show_text, "Show input text", NULL},
{"show-unicode", 0, 0, G_OPTION_ARG_NONE, &this->show_unicode, "Show input Unicode codepoints", NULL},
+ {"show-line-num", 0, 0, G_OPTION_ARG_NONE, &this->show_line_num, "Show line numbers", NULL},
{NULL}
};
parser->add_group (entries,
@@ -750,3 +751,36 @@ format_options_t::serialize_glyphs (hb_buffer_t *buffer,
}
g_string_append_c (gs, '>');
}
+void
+format_options_t::serialize_line_no (unsigned int line_no,
+ GString *gs)
+{
+ if (show_line_num)
+ g_string_append_printf (gs, "%d: ", line_no);
+}
+void
+format_options_t::serialize_line (hb_buffer_t *buffer,
+ unsigned int line_no,
+ const char *text,
+ unsigned int text_len,
+ hb_font_t *font,
+ GString *gs)
+{
+ if (show_text) {
+ serialize_line_no (line_no, gs);
+ g_string_append_len (gs, text, text_len);
+ g_string_append_c (gs, '\n');
+ }
+
+ if (show_unicode) {
+ serialize_line_no (line_no, gs);
+ hb_buffer_reset (scratch);
+ hb_buffer_add_utf8 (scratch, text, text_len, 0, -1);
+ serialize_unicode (buffer, gs);
+ g_string_append_c (gs, '\n');
+ }
+
+ serialize_line_no (line_no, gs);
+ serialize_glyphs (buffer, font, gs);
+ g_string_append_c (gs, '\n');
+}
diff --git a/util/options.hh b/util/options.hh
index 470a313..444569e 100644
--- a/util/options.hh
+++ b/util/options.hh
@@ -285,19 +285,31 @@ struct format_options_t : option_group_t
show_clusters = true;
show_text = false;
show_unicode = false;
+ show_line_num = false;
+ scratch = hb_buffer_create ();
add_options (parser);
}
~format_options_t (void) {
+ hb_buffer_destroy (scratch);
}
void add_options (option_parser_t *parser);
- void serialize_unicode (hb_buffer_t *buffer,
- GString *gs);
- void serialize_glyphs (hb_buffer_t *buffer,
- hb_font_t *font,
- GString *gs);
+ void serialize_unicode (hb_buffer_t *buffer,
+ GString *gs);
+ void serialize_glyphs (hb_buffer_t *buffer,
+ hb_font_t *font,
+ GString *gs);
+ void serialize_line_no (unsigned int line_no,
+ GString *gs);
+ void serialize_line (hb_buffer_t *buffer,
+ unsigned int line_no,
+ const char *text,
+ unsigned int text_len,
+ hb_font_t *font,
+ GString *gs);
+
protected:
hb_bool_t show_glyph_names;
@@ -305,6 +317,9 @@ struct format_options_t : option_group_t
hb_bool_t show_clusters;
hb_bool_t show_text;
hb_bool_t show_unicode;
+ hb_bool_t show_line_num;
+ private:
+ hb_buffer_t *scratch;
};
commit cc4d9810d6318ca2e4de3b8d62f03b51cc21ee05
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Thu Jan 19 12:32:20 2012 -0500
[hb-shape] Add --show-text and --show-unicode options
diff --git a/util/hb-shape.cc b/util/hb-shape.cc
index 906bac2..1910848 100644
--- a/util/hb-shape.cc
+++ b/util/hb-shape.cc
@@ -42,6 +42,7 @@ struct output_buffer_t : output_options_t, format_options_t
protected:
GString *gs;
hb_font_t *font;
+ hb_buffer_t *scratch;
};
void
@@ -50,6 +51,7 @@ output_buffer_t::init (const font_options_t *font_opts)
get_file_handle ();
font = hb_font_reference (font_opts->get_font ());
gs = g_string_new (NULL);
+ scratch = hb_buffer_create ();
}
void
@@ -58,13 +60,28 @@ output_buffer_t::consume_line (hb_buffer_t *buffer,
unsigned int text_len)
{
g_string_set_size (gs, 0);
- serialize (buffer, font, gs);
+
+ if (show_text) {
+ g_string_append_len (gs, text, text_len);
+ g_string_append_c (gs, '\n');
+ }
+
+ if (show_unicode) {
+ hb_buffer_reset (scratch);
+ hb_buffer_add_utf8 (scratch, text, text_len, 0, -1);
+ serialize_unicode (buffer, gs);
+ g_string_append_c (gs, '\n');
+ }
+
+ serialize_glyphs (buffer, font, gs);
fprintf (fp, "%s\n", gs->str);
}
void
output_buffer_t::finish (const font_options_t *font_opts)
{
+ hb_buffer_destroy (scratch);
+ scratch = NULL;
g_string_free (gs, TRUE);
gs = NULL;
hb_font_destroy (font);
diff --git a/util/options.cc b/util/options.cc
index 6585eb4..e497d72 100644
--- a/util/options.cc
+++ b/util/options.cc
@@ -676,6 +676,8 @@ format_options_t::add_options (option_parser_t *parser)
{"no-glyph-names", 0, G_OPTION_FLAG_REVERSE, G_OPTION_ARG_NONE, &this->show_glyph_names, "Use glyph indices instead of names", NULL},
{"no-positions", 0, G_OPTION_FLAG_REVERSE, G_OPTION_ARG_NONE, &this->show_positions, "Do not show glyph positions", NULL},
{"no-clusters", 0, G_OPTION_FLAG_REVERSE, G_OPTION_ARG_NONE, &this->show_clusters, "Do not show cluster mapping", NULL},
+ {"show-text", 0, 0, G_OPTION_ARG_NONE, &this->show_text, "Show input text", NULL},
+ {"show-unicode", 0, 0, G_OPTION_ARG_NONE, &this->show_unicode, "Show input Unicode codepoints", NULL},
{NULL}
};
parser->add_group (entries,
@@ -686,9 +688,27 @@ format_options_t::add_options (option_parser_t *parser)
}
void
-format_options_t::serialize (hb_buffer_t *buffer,
- hb_font_t *font,
- GString *gs)
+format_options_t::serialize_unicode (hb_buffer_t *buffer,
+ GString *gs)
+{
+ unsigned int num_glyphs = hb_buffer_get_length (buffer);
+ hb_glyph_info_t *info = hb_buffer_get_glyph_infos (buffer, NULL);
+
+ g_string_append_c (gs, '<');
+ for (unsigned int i = 0; i < num_glyphs; i++)
+ {
+ if (i)
+ g_string_append_c (gs, ',');
+ g_string_append_printf (gs, "U+%04X", info->codepoint);
+ info++;
+ }
+ g_string_append_c (gs, '>');
+}
+
+void
+format_options_t::serialize_glyphs (hb_buffer_t *buffer,
+ hb_font_t *font,
+ GString *gs)
{
FT_Face ft_face = show_glyph_names ? hb_ft_font_get_face (font) : NULL;
diff --git a/util/options.hh b/util/options.hh
index fbf5f36..470a313 100644
--- a/util/options.hh
+++ b/util/options.hh
@@ -283,6 +283,8 @@ struct format_options_t : option_group_t
show_glyph_names = true;
show_positions = true;
show_clusters = true;
+ show_text = false;
+ show_unicode = false;
add_options (parser);
}
@@ -291,14 +293,18 @@ struct format_options_t : option_group_t
void add_options (option_parser_t *parser);
- void serialize (hb_buffer_t *buffer,
- hb_font_t *font,
- GString *gs);
+ void serialize_unicode (hb_buffer_t *buffer,
+ GString *gs);
+ void serialize_glyphs (hb_buffer_t *buffer,
+ hb_font_t *font,
+ GString *gs);
protected:
hb_bool_t show_glyph_names;
hb_bool_t show_positions;
hb_bool_t show_clusters;
+ hb_bool_t show_text;
+ hb_bool_t show_unicode;
};
commit 27c36af411c7c4d75dd25d79fc76dd92c6bb9643
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Thu Jan 19 12:30:43 2012 -0500
Fix OOB in hb-shape
diff --git a/util/options.cc b/util/options.cc
index 5ded644..6585eb4 100644
--- a/util/options.cc
+++ b/util/options.cc
@@ -631,7 +631,7 @@ text_options_t::get_line (unsigned int *len)
char buf[BUFSIZ];
while (fgets (buf, sizeof (buf), fp)) {
unsigned int bytes = strlen (buf);
- if (buf[bytes - 1] == '\n') {
+ if (bytes && buf[bytes - 1] == '\n') {
bytes--;
g_string_append_len (gs, buf, bytes);
break;
commit 8d2781d69274672303e30522e222bd01c6b5e781
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Thu Jan 19 11:36:39 2012 -0500
[test] Add two Indic test cases from Bernard Massot
diff --git a/test/test-shape-complex.c b/test/test-shape-complex.c
index dea12ec..8f25d8f 100644
--- a/test/test-shape-complex.c
+++ b/test/test-shape-complex.c
@@ -181,6 +181,21 @@ static const test_set_t tests_devanagari2 = {
}
};
+static const test_set_t tests_devanagari3 = {
+ {"Lohit-Devanagari.ttf", 0},
+ {
+ { "Ka Halant Ssa Halant",
+ { 0x0915, 0x094D, 0x0937, 0x094D, 0},
+ { 0x00C4, 0x007D, 0}
+ },
+ { "Ja Halant Nya Halant",
+ { 0x091C, 0x094D, 0x091E, 0x094D, 0},
+ { 0x00C5, 0x007D, 0}
+ },
+ {{0}}
+ }
+};
+
static const test_set_t tests_bengali1 = {
{"AkaashNormal.ttf", 0},
{
@@ -1151,6 +1166,7 @@ main (int argc, char **argv)
TEST_SET (devanagari1);
TEST_SET (devanagari2);
+ TEST_SET (devanagari3);
TEST_SET (bengali1);
TEST_SET (bengali2);
TEST_SET (bengali3);
More information about the HarfBuzz
mailing list