shithub: figlet

ref: 1adf41744cbbdfdb7c834c92bd37280650fb7b5a
dir: /showfigfonts/

View raw version
#!/bin/rc
# showfigfonts by Glenn Chappell <[email protected]>
# figlet release 2.1.1 -- 25 Aug 1994
# Based on showfigfonts by Greg Galperin <[email protected]>, Nov 1993.
#
# adapted for Rc by Lee Duhem <[email protected]>
# February 2007
#
# Prints a list of available figlet fonts, along with a sample of each
# font.  If directory is given, lists fonts in that directory; otherwise
# uses the default font directory.  If word is given, prints that word
# in each font; otherwise prints the font name.
#
# Usage: showfigfonts [ -d directory ] [ word ]

# Set up $path so figlet can be found
path=(. /bin /bin/figlet)

# Get figlet version
FIGLETVERSION=`{figlet -I1 >[2]/dev/null}
if(test -z $FIGLETVERSION)
  FIGLETVERSION=20000

USAGE='Usage: '^ `{basename $0} ^'[ -d directory ] [ word ]'
WORD=''

if(~ $1 -d){
  switch($#*){
    case 2
      FONTDIR=$2
    case 3
      FONTDIR=$2
      WORD=$3
    case *
      echo $USAGE
      exit usage
  }
}
if not {
  if(test $#* -ge 1)
    WORD=$1

  if(test $FIGLETVERSION -lt 20100){
    # figlet 2.0
    FONTDIR=`{eval figlet -F | sed -e '1d' -e '3,$d' -e 's/Font directory://'}
  }
  if not {
    # figlet 2.1 or later
    FONTDIR=`{figlet -I2}
  }
}

SAVEDIR=`{pwd}
cd $FONTDIR
FONTLIST=`{eval ls *.flf | sed 's/\.flf$//'}
cd $SAVEDIR

if(test -n $WORD)
  for(F in $FONTLIST){
    echo $F:
    echo $WORD | figlet -d $FONTDIR -f $F
  }
if not 
  for(F in $FONTLIST){
    echo $F:
    echo $F | figlet -d $FONTDIR -f $F
  }