From ac9b480f8d95a5bcb50dfe0dc2cf914b23572e1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Haoran=20S=2E=20Diao=20=28=E5=88=81=E6=B5=A9=E7=84=B6=29?= <0@hairydiode.xyz> Date: Fri, 30 Jun 2023 02:35:11 -0700 Subject: Added example program for displaying bdf files --- README | 7 +++++++ fontd | 23 +++++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100755 fontd diff --git a/README b/README index 96da413..656d38b 100644 --- a/README +++ b/README @@ -1,3 +1,5 @@ +------------------------------------=[bbrll]=----------------------------------- +Bash Braille: Simple bash script for drawing graphics in the terminal, takes as input drawing commands, and will print either the raw image or the braille version of the image as an output @@ -26,3 +28,8 @@ begin: #ends the script examples are in INPUT and INPUT2 + +------------------------------------=[fontd]=----------------------------------- +Font Display: + prints font in braille characters, useful for limited environments such + as the linux console(although you would need braille support first) diff --git a/fontd b/fontd new file mode 100755 index 0000000..3ca9ae3 --- /dev/null +++ b/fontd @@ -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 -- cgit v1.1