This patch avoids the case where a requested font is not found. It first tries
to load the default font, or exuts with an error. Note that the original patch
entirely removes the two wfree statements. I've added them back as it seemed to
be the Right Thing to do.

Submitted by: Gilbert Ashley <[email protected]>
Author: unknown
Origin: ALT/Sisyphus Linux, Alexey Voinov <[email protected]>


1 file changed, 12 insertions(+), 3 deletions(-)
WINGs/wfont.c |   15 ++++++++++++---


# HG changeset patch
# User John H. Robinson, IV <[email protected]>
# Date 1229204685 28800
# Node ID 5ccc7e50e482ccce80517b4b4f4d6543403d25ed
# Parent  be392fd85635001243fb45fa7d18c294e3f85b5a
Avoid null font

This patch avoids the case where a requested font is not found. It first tries
to load the default font, or exuts with an error. Note that the original patch
entirely removes the two wfree statements. I've added them back as it seemed to
be the Right Thing to do.

Submitted by: Gilbert Ashley <[email protected]>
Author: unknown
Origin: ALT/Sisyphus Linux, Alexey Voinov <[email protected]>

diff --git a/WINGs/wfont.c b/WINGs/wfont.c
--- a/WINGs/wfont.c
+++ b/WINGs/wfont.c
@@ -159,10 +159,19 @@
 
     font->font = XftFontOpenName(display, scrPtr->screen, fname);
     if (!font->font) {
-        wfree(font);
-        wfree(fname);
-        return NULL;
+       printf("Font named %s doesn't exist.\n", fname);
+       printf("Please check your system configuration.\n");
+       printf("Will try default font %s.\n", DEFAULT_FONT);
+       font->font = XftFontOpenName(display, scrPtr->screen, DEFAULT_FONT);
+       if (!font->font) {
+           printf("Unrecoverable font error! I must die!\n");
+           wfree(font);
+           wfree(fname);
+           exit(1);
+       } else
+          printf("Default font loading succeded.\n");
     }
+
     font->height = font->font->ascent+font->font->descent;
     font->y = font->font->ascent;
 

Reply via email to