From: Carl Worth Date: Wed, 13 Feb 2008 18:12:22 +0000 (-0800) Subject: Fix errors to actually abort X-Git-Url: https://git.cworth.org/git?a=commitdiff_plain;h=e84835d20cdfdc0fab3be79eda3335108d36caf4;hp=96d28dc64ae59b5312fd32404561c2307bad8b50;p=spritext Fix errors to actually abort And while we're at it, make the error messages a bit more descriptive. --- 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 );