diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2008-11-05 15:11:32 +0000 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2008-11-05 15:13:02 +0000 |
commit | 2261590875b4be7aa258c51e766f68974750e9e7 (patch) | |
tree | 8abefb038cb5982199129b3f69879224c70006d6 | |
parent | 248dd97075b50cd91619022098ed5dd35a66b5df (diff) |
[trace] Trim a few bytes from glyph arrays
Remove some redundant whitespace from the glyph arrays to improve
readability and shrink the output file size.
-rw-r--r-- | util/cairo-trace/trace.c | 65 |
1 files changed, 38 insertions, 27 deletions
diff --git a/util/cairo-trace/trace.c b/util/cairo-trace/trace.c index c12820e9..2ca184f0 100644 --- a/util/cairo-trace/trace.c +++ b/util/cairo-trace/trace.c @@ -2206,7 +2206,10 @@ _emit_glyphs (cairo_scaled_font_t *font, x = glyphs->x; y = glyphs->y; if (n < num_glyphs) { /* need full glyph range */ - fprintf (logfile, "[ %g %g [", x, y); + bool first; + + fprintf (logfile, "[%g %g [", x, y); + first = true; while (num_glyphs--) { cairo_text_extents_t extents; @@ -2215,10 +2218,14 @@ _emit_glyphs (cairo_scaled_font_t *font, { x = glyphs->x; y = glyphs->y; - fprintf (logfile, " ] %g %g [", x, y); + fprintf (logfile, "] %g %g [", x, y); + first = true; } - fprintf (logfile, " %lu", glyphs->index); + if (! first) + fprintf (logfile, " "); + fprintf (logfile, "%lu", glyphs->index); + first = false; cairo_scaled_font_glyph_extents (font, glyphs, 1, &extents); x += extents.x_advance; @@ -2226,37 +2233,41 @@ _emit_glyphs (cairo_scaled_font_t *font, glyphs++; } - fprintf (logfile, " ] ]"); + fprintf (logfile, "]]"); } else { struct _data_stream stream; - fprintf (logfile, "[ %g %g <~", x, y); - _write_base85_data_start (&stream); - while (num_glyphs--) { - cairo_text_extents_t extents; - unsigned char c; - - if (fabs (glyphs->x - x) > TOLERANCE || - fabs (glyphs->y - y) > TOLERANCE) - { - x = glyphs->x; - y = glyphs->y; - _write_base85_data_end (&stream); - fprintf (logfile, "~> %g %g <~", x, y); - _write_base85_data_start (&stream); - } + if (num_glyphs == 1) { + fprintf (logfile, "[%g %g <%x>]", x, y, glyphs->index); + } else { + fprintf (logfile, "[%g %g <~", x, y); + _write_base85_data_start (&stream); + while (num_glyphs--) { + cairo_text_extents_t extents; + unsigned char c; + + if (fabs (glyphs->x - x) > TOLERANCE || + fabs (glyphs->y - y) > TOLERANCE) + { + x = glyphs->x; + y = glyphs->y; + _write_base85_data_end (&stream); + fprintf (logfile, "~> %g %g <~", x, y); + _write_base85_data_start (&stream); + } - c = glyphs->index; - _write_base85_data (&stream, &c, 1); + c = glyphs->index; + _write_base85_data (&stream, &c, 1); - cairo_scaled_font_glyph_extents (font, glyphs, 1, &extents); - x += extents.x_advance; - y += extents.y_advance; + cairo_scaled_font_glyph_extents (font, glyphs, 1, &extents); + x += extents.x_advance; + y += extents.y_advance; - glyphs++; + glyphs++; + } + _write_base85_data_end (&stream); + fprintf (logfile, "~>]"); } - _write_base85_data_end (&stream); - fprintf (logfile, "~> ]"); } } |