提交 50067e28 编写于 作者: B Behdad Esfahbod

[util] Add --num-iterations

Useful for profiling shapers.
上级 08677c25
...@@ -276,6 +276,7 @@ shape_options_t::add_options (option_parser_t *parser) ...@@ -276,6 +276,7 @@ shape_options_t::add_options (option_parser_t *parser)
{"preserve-default-ignorables",0, 0, G_OPTION_ARG_NONE, &this->preserve_default_ignorables, "Preserve Default-Ignorable characters", NULL}, {"preserve-default-ignorables",0, 0, G_OPTION_ARG_NONE, &this->preserve_default_ignorables, "Preserve Default-Ignorable characters", NULL},
{"utf8-clusters", 0, 0, G_OPTION_ARG_NONE, &this->utf8_clusters, "Use UTF8 byte indices, not char indices", NULL}, {"utf8-clusters", 0, 0, G_OPTION_ARG_NONE, &this->utf8_clusters, "Use UTF8 byte indices, not char indices", NULL},
{"normalize-glyphs",0, 0, G_OPTION_ARG_NONE, &this->normalize_glyphs, "Rearrange glyph clusters in nominal order", NULL}, {"normalize-glyphs",0, 0, G_OPTION_ARG_NONE, &this->normalize_glyphs, "Rearrange glyph clusters in nominal order", NULL},
{"num-iterations", 0, 0, G_OPTION_ARG_INT, &this->num_iterations, "Run shaper N times (default: 1)", "N"},
{NULL} {NULL}
}; };
parser->add_group (entries, parser->add_group (entries,
......
...@@ -150,6 +150,7 @@ struct shape_options_t : option_group_t ...@@ -150,6 +150,7 @@ struct shape_options_t : option_group_t
shapers = NULL; shapers = NULL;
utf8_clusters = false; utf8_clusters = false;
normalize_glyphs = false; normalize_glyphs = false;
num_iterations = 1;
add_options (parser); add_options (parser);
} }
...@@ -234,6 +235,7 @@ struct shape_options_t : option_group_t ...@@ -234,6 +235,7 @@ struct shape_options_t : option_group_t
char **shapers; char **shapers;
hb_bool_t utf8_clusters; hb_bool_t utf8_clusters;
hb_bool_t normalize_glyphs; hb_bool_t normalize_glyphs;
unsigned int num_iterations;
}; };
......
...@@ -51,14 +51,17 @@ struct shape_consumer_t ...@@ -51,14 +51,17 @@ struct shape_consumer_t
{ {
output.new_line (); output.new_line ();
shaper.populate_buffer (buffer, text, text_len, text_before, text_after);
output.consume_text (buffer, text, text_len, shaper.utf8_clusters); output.consume_text (buffer, text, text_len, shaper.utf8_clusters);
if (!shaper.shape (font, buffer)) { for (unsigned int n = shaper.num_iterations; n; n--)
failed = true; {
hb_buffer_set_length (buffer, 0); shaper.populate_buffer (buffer, text, text_len, text_before, text_after);
output.shape_failed (buffer, text, text_len, shaper.utf8_clusters); if (!shaper.shape (font, buffer)) {
return; failed = true;
hb_buffer_set_length (buffer, 0);
output.shape_failed (buffer, text, text_len, shaper.utf8_clusters);
return;
}
} }
output.consume_glyphs (buffer, text, text_len, shaper.utf8_clusters); output.consume_glyphs (buffer, text, text_len, shaper.utf8_clusters);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册