summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHaoran S. Diao (刁浩然) <0@hairydiode.xyz>2023-07-02 05:49:12 -0700
committerHaoran S. Diao (刁浩然) <0@hairydiode.xyz>2023-07-02 05:49:12 -0700
commitfb63015770e5958ba8091e61461dcf39d447f67b (patch)
tree4a3c43ff7df0925b4c40d5be53fdff98a6e9fad5
parent41d9fb69e58c5bec1712409fdf68cae865fcbc2e (diff)
Optimized the awk search in fontd, now it exits when it finds the char instead
of continuing to search the entire font
-rwxr-xr-xfontd8
1 files changed, 4 insertions, 4 deletions
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