From fb63015770e5958ba8091e61461dcf39d447f67b 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: Sun, 2 Jul 2023 05:49:12 -0700 Subject: Optimized the awk search in fontd, now it exits when it finds the char instead of continuing to search the entire font --- fontd | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'fontd') diff --git a/fontd b/fontd index 0925f3f..80ac94c 100755 --- a/fontd +++ b/fontd @@ -12,14 +12,14 @@ eval fonts="$2/*bdf" size=$(cat $fonts | 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}/ENCODING $1$/{if(fflag==0){cflag=1;fflag=1}}/BITMAP/{if (cflag==1){bflag=1};next}/ENDCHAR/{cflag=0;bflag=0}bflag") +#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/\s//g') +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 -- cgit v1.1