[HarfBuzz] harfbuzz-ng: Branch 'master'
Behdad Esfahbod
behdad at kemper.freedesktop.org
Sat Jun 2 09:21:26 PDT 2012
util/options.cc | 4 +---
util/options.hh | 26 ++++++++++++++------------
util/shape-consumer.hh | 4 +++-
3 files changed, 18 insertions(+), 16 deletions(-)
New commits:
commit ae62166519291057316a9d15cea3f1570fcb5eaf
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Sat Jun 2 12:21:19 2012 -0400
[util] Minor
diff --git a/util/options.cc b/util/options.cc
index 4cc8a86..109a0b4 100644
--- a/util/options.cc
+++ b/util/options.cc
@@ -790,9 +790,7 @@ format_options_t::serialize_buffer_of_text (hb_buffer_t *buffer,
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 (scratch, gs);
+ serialize_unicode (buffer, gs);
g_string_append_c (gs, '\n');
}
}
diff --git a/util/options.hh b/util/options.hh
index 849a046..2dcd331 100644
--- a/util/options.hh
+++ b/util/options.hh
@@ -141,7 +141,8 @@ struct view_options_t : option_group_t
struct shape_options_t : option_group_t
{
- shape_options_t (option_parser_t *parser) {
+ shape_options_t (option_parser_t *parser)
+ {
direction = language = script = NULL;
features = NULL;
num_features = 0;
@@ -150,21 +151,23 @@ struct shape_options_t : option_group_t
add_options (parser);
}
- ~shape_options_t (void) {
+ ~shape_options_t (void)
+ {
free (features);
g_free (shapers);
}
void add_options (option_parser_t *parser);
- void setup_buffer (hb_buffer_t *buffer) {
+ void setup_buffer (hb_buffer_t *buffer)
+ {
hb_buffer_set_direction (buffer, hb_direction_from_string (direction, -1));
hb_buffer_set_script (buffer, hb_script_from_string (script, -1));
hb_buffer_set_language (buffer, hb_language_from_string (language, -1));
}
- hb_bool_t shape (const char *text, int text_len,
- hb_font_t *font, hb_buffer_t *buffer) {
+ void populate_buffer (hb_buffer_t *buffer, const char *text, int text_len)
+ {
hb_buffer_reset (buffer);
hb_buffer_add_utf8 (buffer, text, text_len, 0, text_len);
@@ -181,12 +184,17 @@ struct shape_options_t : option_group_t
}
setup_buffer (buffer);
+ }
+
+ hb_bool_t shape (hb_font_t *font, hb_buffer_t *buffer)
+ {
return hb_shape_full (font, buffer, features, num_features, shapers);
}
void shape_closure (const char *text, int text_len,
hb_font_t *font, hb_buffer_t *buffer,
- hb_set_t *glyphs) {
+ hb_set_t *glyphs)
+ {
hb_buffer_reset (buffer);
hb_buffer_add_utf8 (buffer, text, text_len, 0, text_len);
setup_buffer (buffer);
@@ -315,13 +323,9 @@ struct format_options_t : option_group_t
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);
@@ -359,8 +363,6 @@ struct format_options_t : option_group_t
hb_bool_t show_text;
hb_bool_t show_unicode;
hb_bool_t show_line_num;
- private:
- hb_buffer_t *scratch;
};
diff --git a/util/shape-consumer.hh b/util/shape-consumer.hh
index da14c61..220daa4 100644
--- a/util/shape-consumer.hh
+++ b/util/shape-consumer.hh
@@ -48,9 +48,11 @@ struct shape_consumer_t
unsigned int text_len)
{
output.new_line ();
+
+ shaper.populate_buffer (buffer, text, text_len);
output.consume_text (buffer, text, text_len, shaper.utf8_clusters);
- if (!shaper.shape (text, text_len, font, buffer)) {
+ if (!shaper.shape (font, buffer)) {
failed = true;
hb_buffer_set_length (buffer, 0);
output.shape_failed (buffer, text, text_len, shaper.utf8_clusters);
More information about the HarfBuzz
mailing list