summaryrefslogtreecommitdiff
path: root/fonts/utilities/t1tools/getmetri.bat
blob: 7f68f3cf7a48a49113aac55a19feb41ccfdfd409 (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
@echo off
if not "%1"=="-" goto weiter
set dumvar=
set del=rem
shift
:weiter
if not "%1"=="" goto los
echo Parameter: font-file (without .pfb / .pfa suffix) [/FontName]
goto end

:los
rem copy %GS_LIB%\getmetri.ps %TEMP%\getafm$$.ps
if exist %1.pfa goto pfa
if exist %1.pfb goto pfb
echo no font file (.pfb / .pfa) present
goto end
:pfa
type %1.pfa > %TEMP%\getafm$$.ps
goto fontok
:pfb
D:\fonts\progs\t1utils\t1ascii %1.pfb > %TEMP%\getafm$$.ps
:fontok
echo                                    appendnewfont >> %TEMP%\getafm$$.ps
echo fontname %2 getmetric0 quit >> %TEMP%\getafm$$.ps

rem try to save kerning information from previous .afm file 
rem or to extract it from .pfm file
if exist %1.afm goto afmkern
if not exist %1.pfm goto startafm
echo extracting kerning information from %1.pfm
pfm2afm %1
rem dumppfm %1.pfm %1.afm

:afmkern
rem echo saving kerning information from %1.afm
rem egrep -e "^(StartKern|EndKern|KPX)" %1.afm > %TEMP%\%1.kpx
echo saving Composite and KernData information from %1.afm
rem sed -e /StartComposites/,/EndComposites/p -e /StartKernData/,/EndKernData/p -e d < %1.afm > %TEMP%\%1.kpx
sed -e /EndCharMetrics/,/EndFontMetrics/p -e d < %1.afm > %TEMP%\%1.kpx

:startafm
echo generating afm information
gs -q -DNODFONT -DNODISPLAY getmetri.ps %TEMP%\getafm$$.ps | sed -e /StartFontMetrics/,$p -e d > %1.afm

rem insert previously extracted or saved kerning information
if not exist %TEMP%\%1.kpx goto nokern
echo adding kerning and composite information
type %TEMP%\%1.kpx >> %1.afm
rem if sorting of KPX entries is desired, they must be kept apart from CC etc
rem egrep -e "^StartKern" %TEMP%\%1.kpx >> %1.afm
rem egrep -e "^KPX" %TEMP%\%1.kpx | sort >> %1.afm
rem egrep -e "^EndKern" %TEMP%\%1.kpx >> %1.afm
goto fini
:nokern
echo EndCharMetrics>> %1.afm
echo EndFontMetrics>> %1.afm
:fini
if exist %TEMP%\%1.kpx %del% del %TEMP%\%1.kpx
%del% del %TEMP%\getafm$$.ps
:end