summaryrefslogtreecommitdiff
path: root/fonts/utilities/t1tools/getmetric
blob: e58a2a66030c034dbc895bfbb33bafe60a457ee2 (plain)
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
#! /bin/sh

afmdir=${afmdir-afm}

pfafontname () {
	sed -e '/\<eexec\>/q' -e '/\<CharStrings\>/q' |
	sed -e 's,.*FontName *[[{(]\(.*\)[]})].*,\1,' -e t \
	    -e 's,.*FontName[ /]*\([^ ]*\).*,\1,' -e t \
	    -e d
	}

for file in $*
do	font=`basename $file .pfb`
	font=`basename $font .pfa`
	if [ ! -f $font.pfa ]
	then	t1ascii $font.pfb $font.pfa
		delpfa=/bin/rm
	else	delpfa=#
	fi
	FontName=`pfafontname < $font.pfa`

	if [ -f $font.afm ]
	then	echo saving Composite and KernData information from old afm
	#	sed -e /StartComposites/,/EndComposites/p -e /StartKernData/,/EndKernData/p -e d < $font.afm > $font.cck
		sed -e /EndCharMetrics/,/EndFontMetrics/p -e d < $font.afm > $font.cck
	elif [ -f $font.pfm ]
	then
	    echo EndCharMetrics > $font.cck
	    set - ` ( /bin/dd ibs=1 skip=195 count=2 < $font.pfm | /bin/dd conv=swab | /bin/od -d ) 2> /dev/null `
	    pairs=`expr $2 + 0`
	    if [ $pairs -ne 0 ]
	    then
		WinANSI=`dirname $0`/WinANSI
		len=`expr $pairs \* 4`

		set - ` ( /bin/dd ibs=1 skip=131 count=4 < $font.pfm | /bin/dd conv=swab | /bin/od -d ) 2> /dev/null `
		start=`expr $3 \* 65536 + $2 + 2`

		echo StartKernData >> $font.cck
		echo StartKernPairs $pairs >> $font.cck

		/bin/dd ibs=1 skip=$start count=$len < $font.pfm | /bin/dd conv=swab |
		 /bin/od -vbiw4 |
		 sed -e '/^0/N' -e 's,^[0-7]* *\([0-7]*\) \([0-7]*\) [0-7]* [0-7]*[^-0-9]*[-0-9]* *\([-0-9]*\)$,KPX C\2 C\1 \3,' -f ${WinANSI}1 |
		 sed -f ${WinANSI}2 >> $font.cck

		echo EndKernPairs >> $font.cck
		echo EndKernData >> $font.cck
	    else
		echo no kern pairs in $font.pfm
	    fi
	    echo EndFontMetrics >> $font.cck
	fi

	echo /$FontName getmetric0 | gs -DNODISPLAY -q $font.pfa getmetri.ps - > $font.afm

	if [ -f $font.cck ]
	then	cat $font.cck >> $font.afm
	fi

	eval $delpfa $font.pfa
	/bin/rm $font.cck
	if [ -d $afmdir ]
	then	ln $font.afm $afmdir/$FontName.afm
	else	ln $font.afm $FontName.afm
	fi
done