]> git.donarmstrong.com Git - lilypond.git/blob - buildscripts/tfmtoafm.sh
release: 1.1.5
[lilypond.git] / buildscripts / tfmtoafm.sh
1 #!@SHELL@
2 # tfmtoafm.sh --urg
3
4 if [ $# -ne 1 ]; then
5         echo "Usage: tfmtoafm FONT"
6         echo
7         echo "example: tfmtoafm cmr10"
8         exit 2
9 fi
10
11 font=$1
12 afm=$1.afm
13 fontfile=`locate $1.tfm`
14 t1=/tmp/tfmtoafm1-$$
15 t2=/tmp/tfmtoafm2-$$
16 rm -f $t1 $t2 $font $afm
17
18 for i in `seq 1 127`; do printf "%d Character-%d\n" $i $i >> $t1; done
19 tfmtodit $fontfile $t1 $font
20 rm $t1
21 tail -127 $font | cut -f 1-2 > $t1
22 cat $t1 | cut -d, -f 1-2 > $t2
23 rm $t1
24 nl -ba $t2 | sed "s/,/ /g" | sed "s/^ *//" | sed "s/$/ /" | sed "s/^[0-9]*/C &;/" | sed "s/\([0-9]\)\([0-9][0-9][0-9][0-9][0-9]\) /\1.\2 /"g | sed "s/-[0-9]*/&; B 0.00 0.00 /" > $t1
25 cat > $afm <<EOF
26 FontName cmr
27 StartFontMetrics
28 StartCharMetrics
29 EOF
30 # urg 0 is difficult but we need it
31 head -1 $t1 | sed "s/1;/0;/g" >> $afm
32 cat $t1 >> $afm
33 cat >> $afm <<EOF
34 EndCharMetrics
35 EndFontMetrics
36 EOF
37 rm $t1 $t2
38