#!/bin/bash # Show me the (monospace) fonts ;-) # -- # altblue 2005.11.22 # [ -v DEBUG ] && set -x 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:pixelsize=${FONT_SIZE} postscriptname fc-list :lang=en:scalable=true:spacing=dual postscriptname fc-list :lang=en:scalable=true:spacing=mono postscriptname # missing spacing?! how the fuck would you be able to select this shit?! fc-list :postscriptname=CodeNewRoman postscriptname fc-list : postscriptname |egrep ':postscriptname=((Roboto|NotoSans)Mono|NotCourierSans|saxMono)' # no shit, "M+1m" doesn't support "en"… but supports "ie"! fc-list :lang=ie:scalable=true:spacing=dual postscriptname fc-list :lang=ie:scalable=true:spacing=mono postscriptname } mkdir -p screenshots [ -d screenshots ] || bail 'I really want my "screenshots" folder!' idx=0 echo 'Generating screenshots:' fonts_list | sort | uniq | sed 's/:postscriptname=//' | while read postscriptname do idx=$((idx+1)) # dunno what to make xterm use -fa "" family=$(fc-list :postscriptname=$postscriptname family) # argh, some return multiple families - use the last one! family="${family##*,}" file=screenshots/$(echo "$postscriptname" | sed 's/[^a-z0-9-]//gi').jpg echo -ne "\t${idx}. $family (${postscriptname}) … " if [ -f "$file" ] ; then echo 'skipped.' continue fi xterm -fs $FONT_SIZE -fa "${family}:postscriptname=${postscriptname}" -u8 -title "$postscriptname" -class floating -hold \ -geometry 80x25+0+0 -e " echo -e \\\\033[1m${family}-${FONT_SIZE}:postscriptname=${postscriptname}\\\\033[0m\\\\n ;\ cat $INPUT_FILE" & sleep 2 xwd -name "$postscriptname" | xwdtopnm 2>/dev/null | ppmtojpeg > $file kill %% echo "done." done