All pastes #109801 Raw Edit

gen-charmap.sh

public shellscript v1 · immutable
·published 2006-08-01 10:01 UTC
rendered paste body
#!/bin/sh# This assumes you have Python, the ImageMagick binaries in your path,# and the chosen fonts in their respective locations. This also takes# a blank image final.jpg  and writes the characters to it.FONTWIDTH=8FONTPATH="/usr/share/fonts/truetype/ttf-dejavu/DejaVuSansMono.ttf"# Print only printable ASCII charsfor ((i = 32; i < 127; i++))do  # for some reason ImageMagick has problems printing '%'  s=`python -c "print chr($i)" | sed "s/%/?/"`  # catch non-printable characters  if [ `echo -n "$s" | wc -c` != 1 ]  then    s=" "  fi  echo "Writing char $i -- \"$s\"..."  convert -font ${FONTPATH} -pointsize ${FONTWIDTH} -annotate +`expr $i \* ${FONTWIDTH}`+6 "$s" final.png tmp.png#  qiv tmp.png  mv tmp.png final.pngdone