#!/bin/bash # Show me the (monospace) fonts ;-) # -- # altblue 2005.11.22 # INPUT_FILE='unicode-extras.txt' FONT_SIZE=12 CHECK_REQUIRES=0 bail () { echo "$@" ; exit 1; } requires () { [[ "$CHECK_REQUIRES" == "" || $CHECK_REQUIRES -lt 1 ]] && return which which &>/dev/null || bail 'No "which"?! No cookies for you.' echo 'Checking required programs:' for prog in $@ ; do echo -ne "\t$prog ... " which $prog 2>/dev/null || bail 'NOT FOUND!' done } requires fc-list ppmtojpeg sed xterm xwd xwdtopnm # maybe useful/applicable filters: # scalable=True/False # style=Regular/Roman # lang=something is really useful, to be able to easy drop dingbat fonts # ... but some lousy fonters forgot to set it up :( fonts_list () { fc-list :lang=en:scalable=false:size=${FONT_SIZE} family fc-list :lang=en:scalable=true:spacing=100 family } mkdir -p screenshots [ -d screenshots ] || bail 'I really want my "screenshots" folder!' idx=0 echo 'Generating screenshots:' fonts_list | sort | uniq | while read font do idx=$(($idx+1)) file=screenshots/$(echo $font | sed 's/[^a-z0-9]//gi').jpg echo -ne "\t${idx}. ${font} ... " if [ -f "$file" ] ; then echo 'skipped.' continue fi xterm -fs $FONT_SIZE -fa "$font" -u8 -title "$font" -hold \ -geometry 80x25+0+0 -e " echo -e \\\\033[1m${font}-${FONT_SIZE}\\\\033[0m\\\\n ;\ cat $INPUT_FILE" & sleep 2 xwd -name "$font" | xwdtopnm 2>/dev/null | ppmtojpeg > $file kill %% echo "done." done