diff options
-rw-r--r-- | README | 1 | ||||
-rwxr-xr-x | bbrll | 45 | ||||
-rwxr-xr-x | fontd | 8 |
3 files changed, 23 insertions, 31 deletions
@@ -22,6 +22,7 @@ begin: PRINT_RAW or #prints the raw image buffer PRINT_BRAILLE or + #NOTE: THIS ONLY WORKS IF THE CANVAS Consits of only 0s and 1s #prints the output in braille, this uses only the width of the #first row so make sure to call CANVAS or something before hand END @@ -43,6 +43,8 @@ function canvas() { #prints a single braille at $1=x $2=y function print_sin_braille() { +#NOTE, for optimization purposes, this only works if the buffer consits of 1s +#and 0s #bit to braille # #0 3 @@ -51,42 +53,31 @@ function print_sin_braille() { #6 7 #reverse #(1,3)(0,3)(1,2)(1,1)(1,0)(0,2)(0,1)(0,0) - #converts anything other than ., and empty string, or space into 1, else - #0 - prompt='s/[^\. ]/1/;s/^[^1]*$/0/' - b0=$( echo ${rawbuff[((0+4*$2))]:((0+2*$1)):1} | sed "$prompt" ) - b1=$( echo ${rawbuff[((1+4*$2))]:((0+2*$1)):1} | sed "$prompt" ) - b2=$( echo ${rawbuff[((2+4*$2))]:((0+2*$1)):1} | sed "$prompt" ) - b3=$( echo ${rawbuff[((0+4*$2))]:((1+2*$1)):1} | sed "$prompt" ) - b4=$( echo ${rawbuff[((1+4*$2))]:((1+2*$1)):1} | sed "$prompt" ) - b5=$( echo ${rawbuff[((2+4*$2))]:((1+2*$1)):1} | sed "$prompt" ) - b6=$( echo ${rawbuff[((3+4*$2))]:((0+2*$1)):1} | sed "$prompt" ) - b7=$( echo ${rawbuff[((3+4*$2))]:((1+2*$1)):1} | sed "$prompt" ) - #echo "2#$b7$b600$b5$b4$b3$b2$b1$b0" + b0=${rawbuff[((0+4*$2))]:((0+2*$1)):1} + b1=${rawbuff[((1+4*$2))]:((0+2*$1)):1} + b2=${rawbuff[((2+4*$2))]:((0+2*$1)):1} + b3=${rawbuff[((0+4*$2))]:((1+2*$1)):1} + b4=${rawbuff[((1+4*$2))]:((1+2*$1)):1} + b5=${rawbuff[((2+4*$2))]:((1+2*$1)):1} + b6=${rawbuff[((3+4*$2))]:((0+2*$1)):1} + b7=${rawbuff[((3+4*$2))]:((1+2*$1)):1} + + #ors it with the utf-8 hex value of the empty braille character #the two spaces assume aht the encoding is utf-8, convoluted bitwise OR #and coversion between character and number stuff - echo "obase=16;$(( 2#$b7${b6}00$b5$b4$b3$b2$b1$b0 | 0x$(echo -n ⠀ |xxd -p -u)))" |bc | xxd --reverse -ps + echo "obase=16;$(( 2#$b7${b6}00$b5$b4$b3$b2$b1$b0 | 0xE2A080 ))"|bc | xxd --reverse -ps } function print_braille() { #I do the lazy thing and just test the first line w=${#rawbuff[0]} h=${#rawbuff[@]} - #conver to braille coords, since bash rounds down, account for when - #there a braille character that will not be completely filled(it can - #handle this fine because of how the sed pattern was constructed in - #print_sin_braille) - if [ $((w % 2)) -gt 0 ]; then - w=$((w/2+1)) - else - w=$((w/2)) - fi - if [ $((h % 4)) -gt 0 ]; then - h=$((h/4+1)) - else - h=$((h/4)) - fi + #conver to braille coords, we do not want to try to print incomplete + #characters because they will break with our optimization, so rounding + #down is good + w=$((w/2)) + h=$((h/4)) i=0 j=0 while [ $i -lt $h ]; do @@ -18,10 +18,10 @@ bdf=$(cat $2/*bdf | awk "NR==1{fflag=0}/ENCODING $1$/{if(fflag==0){cflag=1;fflag #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') - +#strip all the formating, bbrll takes 0s and 1s as input +sed 's/^.*://g;s/\s[^[:space:]]*$//;s/\s//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 +#echo LOAD_RAW $bin END_RAW PRINT_BRAILLE | sed 's/\s/\n/g' | bbrll +echo LOAD_RAW $bin END_RAW PRINT_RAW | sed 's/\s/\n/g' | bbrll |