#!/bin/bash # Show me the (monospace) fonts ;-) # -- # altblue 2005.11.22 # set -eu [ -v TRACE ] && set -x INPUT_FILE='unicode-extras.txt' FONT_SIZE=12 CHECK_REQUIRES=0 bail () { echo "$*. Bailing out." >&2; 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 printf ' - %s ... ' "$prog" which "$prog" 2>/dev/null || bail 'NOT FOUND!' done } requires fc-list ppmtojpeg sed xterm xwd xwdtopnm trap -- 'kill %%' INT trap -- 'kill %% &>/dev/null || :' EXIT ssdir=screenshots mkdir -p "$ssdir" [ -d screenshots ] || bail "I really want my "$ssdir" folder!" idx=0 echo "Generating screenshots into $ssdir:" # 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 :( # … while some dingbat fonts do declare lang=, … and not decorative &al! # # • much shorter list w/o these variants! ~300 vs. ~1500! # | grep -viE -- '-(Black|Bold|Condensed|Expanded|Ext[A-Z]|Extra|Heavy|Italic|Light|Oblique|Retina|Semi|SmBld|Thin|Ultra)' \ # | grep -viE -- '(Black|Bold|Heavy|It|Ita|Italic|Light|Oblique)$' \ { for pattern in \ :lang=en:scalable=false:pixelsize=${FONT_SIZE} \ :lang=en:scalable=true:spacing=dual \ :lang=en:scalable=true:spacing=mono do fc-list "$pattern" postscriptname fullname done # 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 # missing spacing?! htf would you be able to select this?! #fc-list :postscriptname=CodeNewRoman postscriptname #fc-list : postscriptname | grep -E ':postscriptname=((Roboto|NotoSans)Mono|NotCourierSans|saxMono)' } \ | sort -s \ | uniq \ | while read -r pat do [[ -z $pat ]] && continue # pat=":fullname=Arimo Italic Nerd Font Complete Mono:postscriptname=ArimoNerdFontCompleteM-Italic" idx=$((idx+1)) psn="${pat##*:postscriptname=}" psn="${psn//[^a-zA-Z0-9-]/}" file="$ssdir"/"$psn".jpg fn="${pat##*:fullname=}" fn="${fn%%:postscriptname=*}" echo -n " $idx. $fn ($psn) … " if [[ -e $file ]] ; then if [[ -s $file ]] ; then echo "“$file” already exists: skipped." continue else echo "“$file” already exists, but it is empty: replacing." rm -vf "$file" fi fi xterm \ -fs $FONT_SIZE \ -fa "$pat" \ -u8 \ -title "$fn" \ -class floating \ -hold \ -geometry 80x25+0+0 \ -e "echo -e \\\\033[1m${fn}\\\\033[0m\\\\n ; cat $INPUT_FILE" & sleep 2 xwd -name "$fn" | xwdtopnm 2>/dev/null | ppmtojpeg >"$file" kill %% echo 'done.' ls -l "$file" done