From c8149ca85ed97112778590bc9f090f3ee0254100 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Tue, 13 Nov 2012 11:07:20 -0800 Subject: [PATCH] [hb-shape] Adjust postioning output format 1. If there is any offset (x or y), print out both x and y offsets. 2. Always print out the advance in the major direction of the buffer. Ie. even for zero-advance glyphs, print a "+0". This is more intuitive. --- util/options.cc | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/util/options.cc b/util/options.cc index 9dbc2b1c5..1f626b61f 100644 --- a/util/options.cc +++ b/util/options.cc @@ -616,6 +616,7 @@ format_options_t::serialize_glyphs (hb_buffer_t *buffer, unsigned int num_glyphs = hb_buffer_get_length (buffer); hb_glyph_info_t *info = hb_buffer_get_glyph_infos (buffer, NULL); hb_glyph_position_t *pos = hb_buffer_get_glyph_positions (buffer, NULL); + hb_direction_t direction = hb_buffer_get_direction (buffer); g_string_append_c (gs, '['); for (unsigned int i = 0; i < num_glyphs; i++) @@ -637,14 +638,14 @@ format_options_t::serialize_glyphs (hb_buffer_t *buffer, } if (show_positions && (pos->x_offset || pos->y_offset)) { - g_string_append_c (gs, '@'); - if (pos->x_offset) g_string_append_printf (gs, "%d", pos->x_offset); - if (pos->y_offset) g_string_append_printf (gs, ",%d", pos->y_offset); + g_string_append_printf (gs, "@%d,%d", pos->x_offset, pos->y_offset); } - if (show_positions && (pos->x_advance || pos->y_advance)) { + if (show_positions) { g_string_append_c (gs, '+'); - if (pos->x_advance) g_string_append_printf (gs, "%d", pos->x_advance); - if (pos->y_advance) g_string_append_printf (gs, ",%d", pos->y_advance); + if (HB_DIRECTION_IS_HORIZONTAL (direction) || pos->x_advance) + g_string_append_printf (gs, "%d", pos->x_advance); + if (HB_DIRECTION_IS_VERTICAL (direction) || pos->y_advance) + g_string_append_printf (gs, ",%d", pos->y_advance); } info++;