[hb-view] Add --debug
Frees all allocated memory before exiting. Useful for valgrind run.
This commit is contained in:
parent
b2da26d1e3
commit
1b4a2cc095
|
@ -58,6 +58,7 @@ static const char *language = NULL;
|
||||||
static const char *script = NULL;
|
static const char *script = NULL;
|
||||||
static hb_feature_t *features = NULL;
|
static hb_feature_t *features = NULL;
|
||||||
static unsigned int num_features;
|
static unsigned int num_features;
|
||||||
|
static hb_bool_t debug = FALSE;
|
||||||
|
|
||||||
/* Ugh, global vars. Ugly, but does the job */
|
/* Ugh, global vars. Ugly, but does the job */
|
||||||
static int width = 0;
|
static int width = 0;
|
||||||
|
@ -95,6 +96,7 @@ parse_opts (int argc, char **argv)
|
||||||
int option_index = 0, c;
|
int option_index = 0, c;
|
||||||
static struct option long_options[] = {
|
static struct option long_options[] = {
|
||||||
{"background", 1, 0, 'B'},
|
{"background", 1, 0, 'B'},
|
||||||
|
{"debug", 0, &debug, TRUE},
|
||||||
{"features", 1, 0, 'f'},
|
{"features", 1, 0, 'f'},
|
||||||
{"font-size", 1, 0, 's'},
|
{"font-size", 1, 0, 's'},
|
||||||
{"foreground", 1, 0, 'F'},
|
{"foreground", 1, 0, 'F'},
|
||||||
|
@ -372,6 +374,7 @@ draw (void)
|
||||||
|
|
||||||
if (p != end) {
|
if (p != end) {
|
||||||
glyphs = _hb_cr_text_glyphs (cr, p, end - p, &num_glyphs);
|
glyphs = _hb_cr_text_glyphs (cr, p, end - p, &num_glyphs);
|
||||||
|
|
||||||
cairo_glyph_extents (cr, glyphs, num_glyphs, &extents);
|
cairo_glyph_extents (cr, glyphs, num_glyphs, &extents);
|
||||||
|
|
||||||
y += ceil (font_extents.ascent);
|
y += ceil (font_extents.ascent);
|
||||||
|
@ -381,6 +384,7 @@ draw (void)
|
||||||
cairo_show_glyphs (cr, glyphs, num_glyphs);
|
cairo_show_glyphs (cr, glyphs, num_glyphs);
|
||||||
cairo_restore (cr);
|
cairo_restore (cr);
|
||||||
y += ceil (font_extents.height - ceil (font_extents.ascent));
|
y += ceil (font_extents.height - ceil (font_extents.ascent));
|
||||||
|
|
||||||
cairo_glyph_free (glyphs);
|
cairo_glyph_free (glyphs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -419,5 +423,18 @@ main (int argc, char **argv)
|
||||||
exit (1);
|
exit (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (debug) {
|
||||||
|
free (features);
|
||||||
|
|
||||||
|
cairo_pattern_destroy (fore_pattern);
|
||||||
|
cairo_pattern_destroy (back_pattern);
|
||||||
|
cairo_surface_destroy (surface);
|
||||||
|
cairo_font_face_destroy (cairo_face);
|
||||||
|
cairo_debug_reset_static_data ();
|
||||||
|
|
||||||
|
FT_Done_Face (ft_face);
|
||||||
|
FT_Done_FreeType (ft_library);
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue