From e84835d20cdfdc0fab3be79eda3335108d36caf4 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Wed, 13 Feb 2008 10:12:22 -0800 Subject: [PATCH] Fix errors to actually abort And while we're at it, make the error messages a bit more descriptive. --- spritext.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/spritext.c b/spritext.c index ef7c9a2..1405c48 100644 --- a/spritext.c +++ b/spritext.c @@ -33,6 +33,7 @@ get_max_height (cairo_t *cr, char *characters); int main (void) { + const char font_filename[] = "/srv/rdworth.org/cgi-bin/Verdana.ttf"; char outputJson = FALSE; char characters[] = { @@ -90,16 +91,21 @@ main (void) FT_Vector kerning; error = FT_Init_FreeType( &library ); - if ( error ) - printf("error"); + if ( error ) { + fprintf (stderr, "Fatal error initializing freetype.\n"); + exit (1); + } - error = FT_New_Face( library,"/srv/rdworth.org/cgi-bin/Verdana.ttf", + error = FT_New_Face( library, font_filename, 0, &ft_face ); - if ( error == FT_Err_Unknown_File_Format ) - printf("File opened. Font format unsupported."); - else if ( error ) - printf("Could not be open or read or broken."); + if ( error == FT_Err_Unknown_File_Format ) { + fprintf (stderr, "Unsupported font format: %s\n", font_filename); + exit (1); + } else if ( error ) { + fprintf (stderr, "Failed to open file: %s\n", font_filename); + exit (1); + } use_kerning = FT_HAS_KERNING( ft_face ); -- 2.43.0