#!/bin/bash #USAGE # fontd CHAR DIR # display CHAR if found in any bdf fonts in DIR/ # NOTE: CHAR must be in decimal encoding point format of bdf #expands ~ and *, it's a bit unsafe eval fonts="$2/*bdf" #gets font size, it can take multiple fonts as input so only get the first one #and assume they're all the same size size=$(cat $fonts | grep -m 1 PIXEL_SIZE | awk '{print $2}') #get bdf bitmap info from bdf #cflag labels the character part; bflag labels just the bitmap part, on first #ENDCHAR after finding the bitmap it exits bdf=$(cat $2/*bdf | awk "/ENCODING $1$/{cflag=1}/BITMAP/{if (cflag==1){bflag=1};next}/ENDCHAR/{if (bflag==1){exit}}bflag") #convert to binary, cols depends on size bin=$(echo $bdf | xxd -r -ps | xxd -b -c $(($size/8))|\ #strip all the formating, bbrll takes 0s and 1s as input sed 's/^.*://g;s/\s[^[:space:]]*$//;s/[^01]//g') #saving it as a var removed newlines, must add in with sed, send to bbrll to # display echo LOAD_RAW $bin END_RAW PRINT_BRAILLE | sed 's/\s/\n/g' | bbrll