From c7712c9cb4e66ce8892035a18ba53805caa85dcb Mon Sep 17 00:00:00 2001 From: Manish Singh Date: Wed, 29 Apr 1998 08:47:24 +0000 Subject: [PATCH] don't die on corrupted fonts. Give some error messages instead. -Yosh --- ChangeLog | 5 +++++ app/text_tool.c | 28 +++++++++++++++++++++++++--- app/tools/gimptexttool.c | 28 +++++++++++++++++++++++++--- app/tools/text_tool.c | 28 +++++++++++++++++++++++++--- 4 files changed, 80 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index ae40c281e1..543d1bd974 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Wed Apr 29 01:43:30 PDT 1998 Manish Singh + + * app/text_tool.c: don't die on corrupted fonts. Give some + error messages instead. + Tue Apr 28 23:17:37 PDT 1998 Manish Singh * app/gradient.c: enable adjustment of the gradient list box diff --git a/app/text_tool.c b/app/text_tool.c index db681c07ef..e3d89ef5c7 100644 --- a/app/text_tool.c +++ b/app/text_tool.c @@ -18,7 +18,8 @@ #include #include #include -#include "gdk/gdkkeysyms.h" +#include +#include #include "appenv.h" #include "actionarea.h" #include "buildmenu.h" @@ -1590,7 +1591,22 @@ text_load_font (TextTool *text_tool) weight_str, slant_str, set_width_str, spacing_str, registry_str, encoding_str, fontname)) { + /* Trap errors with bad fonts -Yosh */ + gdk_error_warnings = 0; + gdk_error_code = 0; font = gdk_font_load (fontname); + gdk_error_warnings = 1; + + if (gdk_error_code == -1) + { + char *buf; + buf = g_malloc (strlen (family_str) + 87); + sprintf(buf, "I'm sorry, but the font %s is corrupt.\nPlease ask the system adminstrator to replace it.", family_str); + message_box (buf, NULL, NULL); + g_free (buf); + return FALSE; + } + if (font) { if (text_tool->font) @@ -1758,8 +1774,11 @@ text_render (GImage *gimage, if (!crop) border = 0; /* load the font in */ + gdk_error_warnings = 0; + gdk_error_code = 0; font = gdk_font_load (fontname); - if (!font) + gdk_error_warnings = 1; + if (!font || (gdk_error_code == -1)) return NULL; /* determine the bounding box of the text */ @@ -1934,8 +1953,11 @@ text_get_extents (char *fontname, int line_width, line_height; /* load the font in */ + gdk_error_warnings = 0; + gdk_error_code = 0; font = gdk_font_load (fontname); - if (!font) + gdk_error_warnings = 1; + if (!font || (gdk_error_code == -1)) return FALSE; /* determine the bounding box of the text */ diff --git a/app/tools/gimptexttool.c b/app/tools/gimptexttool.c index db681c07ef..e3d89ef5c7 100644 --- a/app/tools/gimptexttool.c +++ b/app/tools/gimptexttool.c @@ -18,7 +18,8 @@ #include #include #include -#include "gdk/gdkkeysyms.h" +#include +#include #include "appenv.h" #include "actionarea.h" #include "buildmenu.h" @@ -1590,7 +1591,22 @@ text_load_font (TextTool *text_tool) weight_str, slant_str, set_width_str, spacing_str, registry_str, encoding_str, fontname)) { + /* Trap errors with bad fonts -Yosh */ + gdk_error_warnings = 0; + gdk_error_code = 0; font = gdk_font_load (fontname); + gdk_error_warnings = 1; + + if (gdk_error_code == -1) + { + char *buf; + buf = g_malloc (strlen (family_str) + 87); + sprintf(buf, "I'm sorry, but the font %s is corrupt.\nPlease ask the system adminstrator to replace it.", family_str); + message_box (buf, NULL, NULL); + g_free (buf); + return FALSE; + } + if (font) { if (text_tool->font) @@ -1758,8 +1774,11 @@ text_render (GImage *gimage, if (!crop) border = 0; /* load the font in */ + gdk_error_warnings = 0; + gdk_error_code = 0; font = gdk_font_load (fontname); - if (!font) + gdk_error_warnings = 1; + if (!font || (gdk_error_code == -1)) return NULL; /* determine the bounding box of the text */ @@ -1934,8 +1953,11 @@ text_get_extents (char *fontname, int line_width, line_height; /* load the font in */ + gdk_error_warnings = 0; + gdk_error_code = 0; font = gdk_font_load (fontname); - if (!font) + gdk_error_warnings = 1; + if (!font || (gdk_error_code == -1)) return FALSE; /* determine the bounding box of the text */ diff --git a/app/tools/text_tool.c b/app/tools/text_tool.c index db681c07ef..e3d89ef5c7 100644 --- a/app/tools/text_tool.c +++ b/app/tools/text_tool.c @@ -18,7 +18,8 @@ #include #include #include -#include "gdk/gdkkeysyms.h" +#include +#include #include "appenv.h" #include "actionarea.h" #include "buildmenu.h" @@ -1590,7 +1591,22 @@ text_load_font (TextTool *text_tool) weight_str, slant_str, set_width_str, spacing_str, registry_str, encoding_str, fontname)) { + /* Trap errors with bad fonts -Yosh */ + gdk_error_warnings = 0; + gdk_error_code = 0; font = gdk_font_load (fontname); + gdk_error_warnings = 1; + + if (gdk_error_code == -1) + { + char *buf; + buf = g_malloc (strlen (family_str) + 87); + sprintf(buf, "I'm sorry, but the font %s is corrupt.\nPlease ask the system adminstrator to replace it.", family_str); + message_box (buf, NULL, NULL); + g_free (buf); + return FALSE; + } + if (font) { if (text_tool->font) @@ -1758,8 +1774,11 @@ text_render (GImage *gimage, if (!crop) border = 0; /* load the font in */ + gdk_error_warnings = 0; + gdk_error_code = 0; font = gdk_font_load (fontname); - if (!font) + gdk_error_warnings = 1; + if (!font || (gdk_error_code == -1)) return NULL; /* determine the bounding box of the text */ @@ -1934,8 +1953,11 @@ text_get_extents (char *fontname, int line_width, line_height; /* load the font in */ + gdk_error_warnings = 0; + gdk_error_code = 0; font = gdk_font_load (fontname); - if (!font) + gdk_error_warnings = 1; + if (!font || (gdk_error_code == -1)) return FALSE; /* determine the bounding box of the text */