summaryrefslogtreecommitdiff
path: root/bin/makelabel.sh
blob: 24bb750e1617979096f5b0bf1948b1df7e6866cf (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/env bash
USAGE="usage: makelabel.sh labelname x y z < labelcontent"
target="$1"
xoffset=$2
yoffset=$3
zoffset=$4
dirdir0="$(dirname "$(dirname "$0")")"
if [ "_$1" = "_-h" -o "_$1" = "_--help" -o "_$1" = "_-help" ];then
 echo $USAGE 
 exit 0 #we were asked for help and we succeeded with supplying help. :)
fi
if [ "_" = "_$1" -o "_" = "_$2" -o "_" = "_$3" -o "_" = "_$4" ];then
 echo "something is not right. maybe this will help:" >&2
 echo $USAGE >&2
 exit 1 #something fucked up, but let's tell them how they should have done it.
fi
if grep ' ' <<<$1;then
 echo 'fuck. no spaces in $1.'
 exit 1
fi
##target should not have any spaces or else it fucks shit up. >_>... oh well. hex encode it.
while read -rN 1 c;do
 name="$(printf "%02x" "'$c")"
 if [ "$name" = "0a" ]; then
  xoffset=-6
  yoffset="$(printf '%d - %d\n' $yoffset 10 | bc)"
 fi
 if grep "^$name " "${dirdir0}/share/hackvr/font/default.hackvr" 2>&1 > /dev/null;then #don't do this shit unless we actually have something to draw. awk in offsetshape bitches when there's nothing.
   grep "^$name " "${dirdir0}/share/hackvr/font/default.hackvr" \
    | sed 's/^'"$name"'/'"$target"'/' \
    | offsetshape.sh "$xoffset" "$yoffset" "$zoffset"
 fi
 xoffset="$(printf '%d + %d\n' $xoffset 6 | bc)"
done