diff options
author | Haoran S. Diao (刁浩然) <0@hairydiode.xyz> | 2023-06-30 02:35:11 -0700 |
---|---|---|
committer | Haoran S. Diao (刁浩然) <0@hairydiode.xyz> | 2023-06-30 02:35:11 -0700 |
commit | ac9b480f8d95a5bcb50dfe0dc2cf914b23572e1e (patch) | |
tree | 448f7c4f5c9ca50e67c765e5ee0b7f725a6d94c6 /fontd | |
parent | 703ece1f7dc40975b69e1ef52367e86e6561474b (diff) |
Added example program for displaying bdf files
Diffstat (limited to 'fontd')
-rwxr-xr-x | fontd | 23 |
1 files changed, 23 insertions, 0 deletions
@@ -0,0 +1,23 @@ +#!/bin/bash +#USAGE +# fontd CHAR DIR +# display CHAR if found in any bdf fonts in DIR/ + +#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 $2/*bdf | grep -m 1 PIXEL_SIZE | awk '{print $2}') + +#get bdf bitmap info from bdf +#fflag ensures only one result even with multiple bdfs, cflag finds the char, +#bflag labels just the bitmap part +bdf=$(cat $2/*bdf | awk "NR==1{fflag=0}/STARTCHAR $1$/{if(fflag==0){cflag=1;fflag=1}}/BITMAP/{if (cflag==1){bflag=1};next}/ENDCHAR/{cflag=0;bflag=0}bflag") + +#convert to binary, cols depends on size +bin=$(echo $bdf | xxd -r -ps | xxd -b -c $(($size/8))|\ +#strip all the formating, replace '0' with '.' for bbrll +sed 's/^.*://g;s/\s[^[:space:]]*$//;s/\s//g;s/0/\./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 |