Add environment variable FIGLET_FONTDIR

Environment variable FIGLET_FONTDIR can be used to set the path to search
for font files. This variable is used in the test script when FIGlet is
installed on a staging directory.

Signed-off-by: Claudio Matsuoka <cmatsuoka@gmail.com>
This commit is contained in:
Claudio Matsuoka 2011-01-25 23:44:08 -02:00
parent e91b35b234
commit eeaa125de6
5 changed files with 24 additions and 9 deletions

View File

@ -12,6 +12,9 @@ o Add infocode 5 to list supported font formats
o Fix rendering error caused by the previous attempt to fix invalid
memory accesses when smushing at start of line
o New environment variable FIGLET_FONTDIR can be used to specify
the path to search for fonts
o Add regression tests
These changes were made by Claudio Matsuoka <cmatsuoka@gmail.com>

View File

@ -96,7 +96,7 @@ dist:
tar cvf - $(DIST) | gzip -9c > $(DIST).tar.gz
rm -Rf $(DIST)
tar xf $(DIST).tar.gz
(cd $(DIST); make all check vercheck DEFAULTFONTDIR=fonts)
(cd $(DIST); make all check vercheck)
@rm -Rf $(DIST)
@echo
@ls -l $(DIST).tar.gz
@ -104,7 +104,7 @@ dist:
check:
@echo -n "Run tests in "
@pwd
@./run-tests.sh
@./run-tests.sh fonts
@echo
vercheck:

View File

@ -929,6 +929,13 @@ at UTF-8 unicode files,
using the controlfile
.IR utf8 .
.SH ENVIRONMENT
.TP
.B FIGLET_FONTDIR
If
.RB $ FIGLET_FONTDIR
is set, its value is used as a path to search for font files.
.SH FILES
.PD 0
.TP 20

View File

@ -914,7 +914,7 @@ void getparams()
extern int optind;
int c; /* "Should" be a char -- need int for "!= -1" test*/
int columns,infoprint;
char *controlname;
char *controlname,*env;
if ((myname = strrchr(Myargv[0],DIRSEP))!=NULL) {
myname++;
@ -923,6 +923,10 @@ void getparams()
myname = Myargv[0];
}
fontdirname = DEFAULTFONTDIR;
env = getenv("FIGLET_FONTDIR");
if (env!=NULL) {
fontdirname = env;
}
fontname = DEFAULTFONTFILE;
cfilelist = NULL;
cfilelistend = &cfilelist;

View File

@ -4,11 +4,7 @@ TESTDIR=tests
OUTPUT=`mktemp`
LOGFILE=tests.log
CMD=./figlet
if [ -n "$1" ]; then
FONTDIR="-d $1"
CMD="$CMD $FONTDIR"
fi
FONTDIR="$1"
run_test() {
test_num=$1
@ -39,10 +35,15 @@ file="$TESTDIR/input.txt"
cmd="cat $file|$CMD"
echo -n "Default font dir: "; $CMD -I2
if [ -n "$FONTDIR" ]; then
FIGLET_FONTDIR="$FONTDIR"
export FIGLET_FONTDIR
fi
echo -n "Current font dir: "; $CMD -I2
echo -n "Default font: "; $CMD -I3
echo
run_test 001 "showfigfonts output" "./showfigfonts $FONTDIR"
run_test 001 "showfigfonts output" "./showfigfonts"
run_test 002 "text rendering in all fonts" \
"for i in fonts/*.flf; do $cmd -f \$i; done"
run_test 003 "long text rendering" "cat tests/longtext.txt|./figlet"