lilypond-1.3.23
[lilypond.git] / buildscripts / tfmtoafm.sh
blobf598a8657acf9d2b1bbd6e85f5e9c180da4c399a
1 #!@SHELL@
2 # tfmtoafm.sh --urg
4 if [ $# -ne 1 ]; then
5 echo "Usage: tfmtoafm FONT"
6 echo
7 echo "example: tfmtoafm cmr10"
8 exit 2
9 fi
11 font=$1
12 size=`echo $font | sed "s/[^0-9]*//"`
13 afm=$1.afm
14 fontfile=`kpsewhich $1.tfm`
15 t1=/tmp/tfmtoafm1-$$
16 t2=/tmp/tfmtoafm2-$$
17 rm -f $t1 $t2 $font $afm
19 for i in `seq 1 127`; do printf "%d Character-%d\n" $i $i >> $t1; done
20 tfmtodit $fontfile $t1 $font
21 rm $t1
22 scaling=`nawk -v OFMT='%.5f' '/designsize/ {print $2/'$size/1000} $font`
23 tail -127 $font | cut -f 1-2 > $t1
24 cat $t1 | cut -d, -f 1-2 > $t2
25 rm $t1
26 nl -ba $t2 | nawk -F '[ \t,]+' '{print "C "$2";\t"$3";\tB 0.00 0.00 "$4/'"$scaling"'" "$5/'"$scaling"'";"}' > $t1
28 cat > $afm <<EOF
29 FontName cmr
30 StartFontMetrics
31 StartCharMetrics
32 EOF
33 # urg 0 is difficult but we need it
34 head -1 $t1 | sed "s/1;/0;/g" >> $afm
35 cat $t1 >> $afm
36 cat >> $afm <<EOF
37 EndCharMetrics
38 EndFontMetrics
39 EOF
40 rm $t1 $t2