-
-
Notifications
You must be signed in to change notification settings - Fork 25
/
os2_patch.sh
executable file
·74 lines (58 loc) · 2.81 KB
/
os2_patch.sh
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/bin/bash
BASE_DIR=$(cd $(dirname $0); pwd)
PREFIX="$1"
xAvgCharWidth_SETVAL=540
HACKGEN_PATTERN=${PREFIX}'HackGen[^3]*.ttf'
xAvgCharWidth53_SETVAL=1030
HACKGEN53_PATTERN=${PREFIX}'HackGen35*.ttf'
for P in ${BASE_DIR}/${HACKGEN_PATTERN}; do
ttx -t OS/2 -t post "$P"
xAvgCharWidth_value=$(grep xAvgCharWidth "${P%%.ttf}.ttx" | awk -F\" '{print $2}')
sed -i.bak -e 's,xAvgCharWidth value="'$xAvgCharWidth_value'",xAvgCharWidth value="'${xAvgCharWidth_SETVAL}'",' "${P%%.ttf}.ttx"
fsSelection_value=$(grep fsSelection "${P%%.ttf}.ttx" | awk -F\" '{print $2}')
if [ `echo $P | grep Regular` ]; then
fsSelection_sed_value='00000000 01000000'
elif [ `echo $P | grep BoldOblique` ]; then
fsSelection_sed_value='00000000 00100001'
elif [ `echo $P | grep Bold` ]; then
fsSelection_sed_value='00000000 00100000'
elif [ `echo $P | grep Oblique` ]; then
fsSelection_sed_value='00000000 00000001'
fi
sed -i.bak -e 's,fsSelection value="'"$fsSelection_value"'",fsSelection value="'"$fsSelection_sed_value"'",' "${P%%.ttf}.ttx"
underlinePosition_value=$(grep 'underlinePosition value' "${P%%.ttf}.ttx" | awk -F\" '{print $2}')
sed -i.bak -e 's,underlinePosition value="'$underlinePosition_value'",underlinePosition value="-70",' "${P%%.ttf}.ttx"
sed -i.bak -e 's,<isFixedPitch value="0"/>,<isFixedPitch value="1"/>,' "${P%%.ttf}.ttx"
mv "$P" "${P}_orig"
ttx -m "${P}_orig" "${P%%.ttf}.ttx"
if [ $? -eq 0 ]; then
mv "${P}_orig" "${BASE_DIR}/bak/"
mv "${P%%.ttf}.ttx" "${BASE_DIR}/bak/"
rm "${P%%.ttf}.ttx.bak"
fi
done
for P in ${BASE_DIR}/${HACKGEN53_PATTERN}; do
ttx -t OS/2 -t post "$P"
xAvgCharWidth_value=$(grep xAvgCharWidth "${P%%.ttf}.ttx" | awk -F\" '{print $2}')
sed -i.bak -e 's,xAvgCharWidth value="'$xAvgCharWidth_value'",xAvgCharWidth value="'${xAvgCharWidth53_SETVAL}'",' "${P%%.ttf}.ttx"
fsSelection_value=$(grep fsSelection "${P%%.ttf}.ttx" | awk -F\" '{print $2}')
if [ `echo $P | grep Regular` ]; then
fsSelection_sed_value='00000000 01000000'
elif [ `echo $P | grep BoldOblique` ]; then
fsSelection_sed_value='00000000 00100001'
elif [ `echo $P | grep Bold` ]; then
fsSelection_sed_value='00000000 00100000'
elif [ `echo $P | grep Oblique` ]; then
fsSelection_sed_value='00000000 00000001'
fi
sed -i.bak -e 's,fsSelection value="'"$fsSelection_value"'",fsSelection value="'"$fsSelection_sed_value"'",' "${P%%.ttf}.ttx"
underlinePosition_value=$(grep 'underlinePosition value' "${P%%.ttf}.ttx" | awk -F\" '{print $2}')
sed -i.bak -e 's,underlinePosition value="'$underlinePosition_value'",underlinePosition value="-70",' "${P%%.ttf}.ttx"
mv "$P" "${P}_orig"
ttx -m "${P}_orig" "${P%%.ttf}.ttx"
if [ $? -eq 0 ]; then
mv -f "${P}_orig" "${BASE_DIR}/bak/"
mv -f "${P%%.ttf}.ttx" "${BASE_DIR}/bak/"
rm -f "${P%%.ttf}.ttx.bak"
fi
done