From a5f4d401fc2e9f9c9f03a8d3af33a20f50065e89 Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Mon, 8 Feb 2010 23:34:05 +0000 Subject: [PATCH] Search for missing fonts in the current directory (Fixes #40) and display an error message in case of failure. --- doc/toilet.1.in | 1 + src/figlet.c | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/doc/toilet.1.in b/doc/toilet.1.in index 713a22c..1acd6b4 100644 --- a/doc/toilet.1.in +++ b/doc/toilet.1.in @@ -56,6 +56,7 @@ or .B .tlf files stored in the .B @datarootdir@/figlet +directory. Fonts are looked first in the font directory, then in the current directory. There is also a special built-in font called .I term that serves as a fallback if no font is available. diff --git a/src/figlet.c b/src/figlet.c index cf3ec17..04f2849 100644 --- a/src/figlet.c +++ b/src/figlet.c @@ -42,7 +42,14 @@ int init_figlet(context_t *cx) snprintf(path, 2047, "%s/%s", cx->dir, cx->font); if(caca_canvas_set_figfont(cx->cv, path)) - return -1; + { + snprintf(path, 2047, "./%s", cx->font); + if(caca_canvas_set_figfont(cx->cv, path)) + { + fprintf(stderr, "error: could not load font %s\n", cx->font); + return -1; + } + } cx->feed = feed_figlet; cx->flush = flush_figlet;