From 15c3c47514b04bfd2f9222ebbdbd972f8b916cb8 Mon Sep 17 00:00:00 2001 From: kramm Date: Thu, 12 Aug 2004 12:57:17 +0000 Subject: [PATCH] added more graceful error handling. --- lib/modules/swffont.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/lib/modules/swffont.c b/lib/modules/swffont.c index 49c5677..ba73409 100644 --- a/lib/modules/swffont.c +++ b/lib/modules/swffont.c @@ -117,8 +117,10 @@ SWFFONT* swf_LoadTrueTypeFont(char*filename) fprintf(stderr, "Couldn't load file %s- not a TTF file?\n", filename); return 0; } - if(face->num_glyphs <= 0) + if(face->num_glyphs <= 0) { + fprintf(stderr, "File %s contains %d glyphs\n", face->num_glyphs); return 0; + } font = malloc(sizeof(SWFFONT)); memset(font, 0, sizeof(SWFFONT)); @@ -215,9 +217,15 @@ SWFFONT* swf_LoadTrueTypeFont(char*filename) continue; } error = FT_Load_Glyph(face, t, FT_LOAD_NO_BITMAP|FT_LOAD_NO_SCALE); - if(error) return 0; + if(error) { + fprintf(stderr, "Couldn't load glyph %d\n", t); + continue; + } error = FT_Get_Glyph(face->glyph, &glyph); - if(error) return 0; + if(error) { + fprintf(stderr, "Couldn't get glyph %d\n", t); + continue; + } FT_Glyph_Get_CBox(glyph, ft_glyph_bbox_unscaled, &bbox); bbox.yMin = -bbox.yMin; @@ -239,7 +247,13 @@ SWFFONT* swf_LoadTrueTypeFont(char*filename) //error = FT_Outline_Decompose(&face->glyph->outline, &outline_functions, &draw); error = FT_Outline_Decompose(&face->glyph->outline, &outline_functions, &draw); - if(error) return 0; + draw.finish(&draw); + + if(error) { + fprintf(stderr, "Couldn't decompose glyph %d\n", t); + draw.dealloc(&draw); + continue; + } draw.finish(&draw); -- 1.7.10.4