Search for missing fonts in the current directory (Fixes #40) and display

an error message in case of failure.
This commit is contained in:
Sam Hocevar 2010-02-08 23:34:05 +00:00 committed by sam
parent ab698bbc1f
commit a5f4d401fc
2 changed files with 9 additions and 1 deletions

View file

@ -56,6 +56,7 @@ or
.B .tlf .B .tlf
files stored in the files stored in the
.B @datarootdir@/figlet .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 directory. There is also a special built-in font called
.I term .I term
that serves as a fallback if no font is available. that serves as a fallback if no font is available.

View file

@ -42,7 +42,14 @@ int init_figlet(context_t *cx)
snprintf(path, 2047, "%s/%s", cx->dir, cx->font); snprintf(path, 2047, "%s/%s", cx->dir, cx->font);
if(caca_canvas_set_figfont(cx->cv, path)) if(caca_canvas_set_figfont(cx->cv, path))
{
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; return -1;
}
}
cx->feed = feed_figlet; cx->feed = feed_figlet;
cx->flush = flush_figlet; cx->flush = flush_figlet;