summaryrefslogtreecommitdiff
path: root/fonts/utilities/t1tools/afm-pfm.bat
blob: a9fa22bc8f539c2f1fdd13b4b0ae6a2996c75520 (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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
@echo off
set dumvar=
set del=
if not "%1"=="-" goto mach
set del=rem
shift

:mach
if exist %1.afm goto los
echo "Parameter: [-] fontfile [without afm suffix] [MSMenuName | - ] [N | I | B | T]"
goto end

:los
set enc=C:\Adobe\foundry\w
if exist %1.enc set enc=%1
if exist %1.inf goto makepfminf

egrep CapHeight %1.afm > %1.inf
if not errorlevel 1 goto capok
egrep FontBBox %1.afm | sed "s,.* \([-0-9][-0-9]*\) *$,CapHeight \1," > %1.inf
:capok
echo Serif true >> %1.inf
echo Pi false >> %1.inf
:getstyle
if "%3"=="" goto genstyle
echo VPStyle (%3) >> %1.inf
goto getname
:genstyle
egrep "FontName.*(Demi|Semi|Bold|Heavy|Black|Ultra|Three)" %1.afm > nul
if errorlevel 1 goto testweight
goto testobl
:testweight
egrep "Weight.*(Demi|Semi|Bold|Heavy|Black|Ultra)" %1.afm > nul
if errorlevel 1 goto notbold
:testobl
egrep "FontName.*(Italic|Oblique|Slanted)" %1.afm > nul
if errorlevel 1 goto bold
echo ItalicAngle -20 >> %1.inf
echo VPStyle (T) >> %1.inf
goto getname
:bold
echo VPStyle (B) >> %1.inf
goto getname
:notbold
egrep "FontName.*(Italic|Oblique|Slanted)" %1.afm > nul
if errorlevel 1 goto normal
echo ItalicAngle -20 >> %1.inf
echo VPStyle (I) >> %1.inf
goto getname
:normal
echo VPStyle (N) >> %1.inf

:getname
if "%2"=="" goto genname
if "%2"=="-" goto genname
if not "%3"=="" echo DOS command restriction: family name may not contain blanks
echo MSMenuName (%2) >> %1.inf
goto makepfm

rem this was used with dos grep and without sed:
:gennameold
grep FamilyName %1.afm | sort > MSMenu$$.bat
call MSMenu$$.bat
type MSMenu$$.i >> %1.inf
%del% del MSMenu$$.bat
%del% del MSMenu$$.i
goto makepfm

:genname
egrep -e FamilyName %1.afm | sed "s,FamilyName *\(.*\) *$,MSMenuName (\1)," >> %1.inf
rem with DOS grep, grep -o could be used here instead of egrep -e

:makepfm
C:\Adobe\foundry\makepfm.exe -e %enc%.enc -i %1.inf -l nul %1.afm
%del% del %1.inf
if exist %1.pfm goto end
goto error

:makepfminf
C:\Adobe\foundry\makepfm.exe -e %enc%.enc -i %1.inf -l nul %1.afm
if exist %1.pfm goto end

:error
echo off
echo    makepfm failed. Possible errors:
echo 1. CapHeight entry must be present (last value of B box of letter H)
echo 2. StartCharMetrics entry must contain exact number of character entries
echo 3. Character entries must have B box information. To fake them, take 
echo    the FontBBox x1 y1 x2 y2 entry and insert behind every character's 
echo    N (name) entry: B x1 y1 x2 y2 ;
echo 4. makepfm doesn't seem to like character position 0 in afm files
echo 5. .inf file was not built properly
:end