first commit

master
Gogs 9 years ago
parent 3295e5fea4
commit 73ea383041
  1. 12
      figlet.awk
  2. 23
      generate.sh
  3. 16
      prettyPrintSnippet.sh

@ -0,0 +1,12 @@
BEGIN { char_cnt=32; line_cnt=0; print "#!/bin/bash\ndeclare -A a" } # echo bash shebang + declaring associative array for string keys
NR==1 {height=$2; start=$6; print "height=" $2} # interpreting flf first line variables
NR-start-1>0 && char_cnt<123 { # for every line with characters definitions:
line=$0;
gsub("@","",line); # replace all "@" with blank
gsub("\$"," ",line); # replace all dollar signs with blank space
gsub("'","'\"'\"'",line); # replace every occurance of single quote, with escape
printf "a[\"%i,%i\"]='%s';", char_cnt, line_cnt, substr(line,2) # print array formated characters
line_cnt++;
}
char_cnt<123 && match($0, /@@$/) { char_cnt++; line_cnt=0; print "" }

@ -0,0 +1,23 @@
#!/bin/bash
if [ $# -eq 0 ]; then
echo "No arguments supplied"
exit 1
fi
if [[ "$1" != *.flf ]]; then
echo "Are you sure you supplied FIGlet font file?"
exit 1
fi
f=`basename "$1"`
output="${f%.flf}.sh"
if [ -f $output ]; then
echo "File $output already exists. Aborting."
exit 1
fi
awk -f figlet.awk $1 > $output
cat prettyPrintSnippet.sh >> $output
chmod +x $output
echo "Successfuly written to file $output"

@ -0,0 +1,16 @@
function prettyPrint {
str=$1
strarr=()
for (( i=0; i<${#str}; i++ )); do
strarr+=(`printf '%d\n' "'${str:$i:1}"`)
done
for ((i=0;i<$height;i++)) do
for j in "${strarr[@]}"; do
printf "%s" "${a["$j,$i"]}"
done
printf "\n"
done
}
prettyPrint $1
Loading…
Cancel
Save