summaryrefslogtreecommitdiff
path: root/fonts/psfonts/tools/famtool.pl
blob: f9dee006f32b7b9c930f5553a50214c1b2afcfb5 (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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
#
# Perl subroutines to support the AFM to TFM font conversion
# scripts using fontinst
#
# Sebastian Rahtz, January 1997
#
# 1.0 January 1997
# 1.1 1997/02/09
# 1.2 1997/02/13
# 1.3 1997/09/17
# 1.4 1997/10/04
# 1.5 1998/05/19, with help from Ulrik Vieth
# 1.6 1998/06/02, correction from UV
# 1.7 1998/07/04, small changes for fontinst 1.8 and other cleanups
#-----------------------------------------------------------------
sub texSetup {
#
# get the date right
#
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =
						localtime(time);
$year = $year + 1900;
$mon = $mon +1 ;
if ($mon < 10) { $mon= "0" . $mon; } 
if ($mday < 10) { $mday= "0" . $mday; } 
$Inidir = getcwd();
if (&IsWin32) {
$ENV{TFMFONTS}=".;";
}
else
{
$ENV{TFMFONTS}=".:";
}

}
sub Setup {
my ($JOB) = @_;
&texSetup;
if ($opt_outdir eq "") { $opt_outdir=$Inidir; }
&readfontnames;
$_=$JOB;
($sname,$fname,$famextra) = /(.)(..)(.*)/;
$Famcode=$sname . $fname;
$Foundry=$Foundries{$sname};
$Family=$Typefaces{$fname};
$ShortFamily=$Shortnames{$fname} . $opt_extra;
$Outdir="$opt_outdir/$Foundry/$ShortFamily";
if (! -d "$opt_outdir")
 { mkdir("$opt_outdir",0777) 
	|| die ("cannot make $opt_outdir"); }
if (! -d "$opt_outdir/$Foundry")
  { mkdir("$opt_outdir/$Foundry",0777) 
	|| die ("cannot make $opt_outdir/$Foundry"); }
mkdir("$opt_outdir/$Foundry/$ShortFamily",0777);
mkdir("$Outdir/dvips",0777);
mkdir("$Outdir/tfm",0777);
mkdir("$Outdir/vf",0777);
mkdir("$Outdir/vpl",0777);
mkdir("$Outdir/pl",0777);
mkdir("$Outdir/tex",0777);
print "work on $Famcode$opt_expert ($famextra) / $ShortFamily / $Family\n"  if $opt_verbose;
print "TeX search path is $ENV{TEXINPUTS}\n";
#
# convert relative path to absolute, since we are operating from /tmp
#
chdir("$Outdir") || die ("cannot change directory to $Outdir");
$Outdir = getcwd();
print "results to $Outdir\n";
if (! -d "/tmp/Fam_$$")
  { mkdir("/tmp/Fam_$$",0777)
	|| die ("cannot make dir /tmp/Fam_$$"); }
chdir("/tmp/Fam_$$")      || die ("cannot change dir to /tmp/Fam_$$");
}

#-----------------------------------------------------------------
sub buildfilelist {
    opendir(DIR,'.') 
    || die ("ERROR: cannot open directory");
    @filenames =grep(!/^\.\.?$/,readdir(DIR));
    closedir(DIR);
}
#-----------------------------------------------------------------
sub readfontnames
{
my $colA,$colB,$ColC,$ColD;
open(SH,"kpsewhich supplier.map |") 
    || die "cannot run kpsewhich to get supplier.map"; 
 $path=<SH>;
 chop $path;
 close(SH); 

open(INF,"$path") || die "cannot open $path";
 while (<INF>){  
    if (!/^@/) { 
      ($ColA,$ColB,$ColC)=split;
      $Foundries{$ColA} =$ColB; 
       }
    }
close(INF);
open(SH,"kpsewhich typeface.map |") 
    || die "cannot run kpsewhich to get supplier.map"; 
 $path=<SH>;
 chop $path;
 close(SH); 
open(INF,"$path") || die "cannot open $path";
 while (<INF>){  
    if (!/^@/) { 
      ($ColA,$ColB,$ColC,$ColD)=split;
      $Typefaces{$ColA} =$ColC; 
      $Shortnames{$ColA} =$ColB; 
       }
    }
close(INF);
}

#-----------------------------------------------------------------
sub readAFMfile {
     my ($AFMfile) = @_;
     my $FontName;
     open(AFM,$AFMfile);
     while (<AFM>) {
        if (/^FontName /) 
            { ($FontName) = /^FontName ([A-z0-9\-]*)/ ; return $FontName; }
      }
     close(AFM);
     return "";
}
#-----------------------------------------------------------------
sub installDvips {
$TeXBaseEncoding=`kpsewhich -format='dvips config' 8r.enc`; 
chop $TeXBaseEncoding;
open(MAP,">>$Outdir/dvips/$Famcode$opt_extra$famextra.map");
# 8r names
print "** Making map entries for 8r *.pl files\n";
for (grep(/.{3,}8r.*\.pl/,@filenames)) { 
   s/\.pl//;
   $Basefile=$_;
   s/8r([a-z]?)$/8a$1/;
   $AFMfile=`kpsewhich $_.afm`;
   if ($AFMfile eq "")
   {
      $_=$Basefile;
      s/8r[a-z]?$/8a/;
      $Rawfile=$_;
      $AFMfile=`kpsewhich $_.afm`;
   }
   else
   {
      $Rawfile=$_;
   }
   chop $AFMfile ;
   if ($AFMfile ne "")
   {
    $FontName=&readAFMfile($AFMfile);
    $FullNames{$Basefile}=$FontName;
    print MAP "$Basefile $FontName \"TeXBase1Encoding ReEncodeFont \" <8r.enc ";
    if ($opt_download) { print MAP "<$Rawfile.pfb"; }
    print MAP "\n";
    &make_tfm($Basefile,$AFMfile,"-e$TeXBaseEncoding");
    }
}
# 8x names
print "** Making map entries for 8x *.pl files\n" if $opt_verbose;
for (grep(/.*8x.*\.pl/,@filenames)) { 
   s/\.pl//;
   $Basefile=$_;
   $AFMfile=`kpsewhich $_.afm`;
   chop $AFMfile ;
   if ($AFMfile ne "")
   {
    $FontName=&readAFMfile($AFMfile);
    $FullNames{$Basefile}=$FontName;
    print MAP "$Basefile $FontName ";
    if ($opt_download) { print MAP "<$Basefile.pfb"; }
    print MAP "\n";
    &make_tfm($Basefile,$AFMfile,"");
    }
 }
print "** Making map entries for faked fonts\n" if $opt_verbose;
open LOG,"grep \"^Faking \" *.log| " 
    || die "cannot open grep for Faking";
while (<LOG>) {
 ($Style,$Fake,$Real)=/Faking (.*) font (.*) from (.*)/;
 $_=$Real;
# Up must match at least 3 chars, because of StoneSans ps8 family....
 ($Up,$Enc,$Suf) = /(.{3,})(8.)(.*)/;
# print "SHOW ME $Up, $Enc, $Suf from $Real\n";
 $Basefile="$Up$Enc$Suf";
 $Enc =~ s/8r/8a/;
 $Rawfile="$Up$Enc$Suf";
 $AFMfile=`kpsewhich $Rawfile.afm`;
 chop $AFMfile ;
 $csargs="";
 if ($AFMfile ne "")
   {
   $FontName=&readAFMfile($AFMfile);
   print MAP "$Fake $FontName \"";
   if ($Style eq "narrow") {    
               print MAP " $opt_narrow ExtendFont" ;
	       $csargs=" -E$opt_narrow "; 
	       }
   elsif ($Style eq "oblique")  {    
                print MAP " $opt_slant SlantFont" ; 
	        $csargs=" -S$opt_slant "; 
	       }
   if ($Enc ne "8x") { 
        print MAP " TeXBase1Encoding ReEncodeFont \" <8r.enc"; 
	$csargs .= "-e$TeXBaseEncoding ";
	}
   else { print MAP "\"";}
   if ($opt_download) { print MAP " <$Rawfile.pfb " ; }
   print MAP "\n";
   &make_tfm($Fake,$AFMfile,$csargs);
  }
}
close LOG;
close MAP;
open CONFIG,">>$Outdir/dvips/config.$Famcode$opt_extra";
print CONFIG  "p +$Famcode$opt_extra.map$famextra\n" ;
close CONFIG;
}

#-----------------------------------------------------------------

sub installMetrics {
print "** Making virtual fonts with vptovf\n" if $opt_verbose;
for (grep(/.*\.vpl/,@filenames)) { 
    s/.vpl//;
    my $Basename=$_;
    processVPL($Basename);
 }
 &buildfilelist;
print "** Installing TFM files in $Outdir/tfm\n" if $opt_verbose;
 for (grep(/.*\.tfm/,@filenames)) { 
 print "Installing $_ \n" if $opt_verbose;
 if (! -r "$Outdir/tfm/$_") { runsystem("mv $_ $Outdir/tfm") ;  }
  }
print "** Installing VF files in $Outdir/vf\n" if $opt_verbose;
 for (grep(/.*\.vf/,@filenames)) {
  print "Installing $_ \n" if $opt_verbose;
  if (! -r "$Outdir/vf/$_") { runsystem("mv $_ $Outdir/vf") ; }
 }
print "** Installing VPL files in $Outdir/vpl\n" if $opt_verbose;
 for (grep(/.*\.vpl/,@filenames)) {
  print "Installing $_ \n" if $opt_verbose;
  if (! -r "$Outdir/vpl/$_") { runsystem("mv $_ $Outdir/vpl") ; }
 }
print "** Installing PL files in $Outdir/pl\n" if $opt_verbose;
 for (grep(/.*\.pl/,@filenames)) {
  print "Installing $_ \n" if $opt_verbose;
  if (! -r "$Outdir/pl/$_") { runsystem("mv $_ $Outdir/pl") ; }
}
}

#-----------------------------------------------------------------
sub make_tfm {
# Add CHECKSUM in the same way as AFM2TFM and PS2PK do
# This is originally by Piet Tutelaers <rcpt@urc.tue.nl>
   local($texname,$afmfile,$csargs) = @_;
   local $cs = 0;
   if (-r "$texname.tfm") { 
          chop($cs = `cs -o "$texname.tfm"`);
          return $cs; 
    }
   chop($cs = `cs -n -o $csargs $afmfile`);
   print "make tfm $texname, $afmfile, $csargs\n" if $opt_debug;
   die "[addchecksum] cs: exit code ", ($? >>8) & 255, "\n" if $cs == 0 && $?;

   die "[addchecksum] Wrong checksum for $texname\n" if "$cs" eq "";
   print "$texname.pl: cs -n -o $csargs $afmfile -> $cs\n" if $opt_verbose;
   die "[addchecksum] Can not open $texname.pl\n" unless open(PL, "<$texname.pl");
	 $csadded = 0;
   open(TMPPL, ">tmp.pl");
   print TMPPL "(COMMENT new CHECKSUM added)\n";
   while (<PL>) {
      if (/CHECKSUM/) {
         print TMPPL "(CHECKSUM O $cs)\n";
	 $csadded = 1;
	 next;
      }
      if ($csadded == 0 && /FONTDIMEN/) {
         print TMPPL "(CHECKSUM O $cs)\n";
	 $csadded = 1;
      }
      print TMPPL;
   }
   close(PL); close(TMPPL);
   unlink("$texname.pl");
   rename("tmp.pl", "$texname.pl");
   print "pltotf $texname.pl $texname.tfm\n" if $opt_debug;
   runsystem("pltotf $texname.pl $texname.tfm");
   die "[addchecksum] pltotf: exit code ", ($? >>8) & 255, "\n" if $?;
   return $cs;
}

#-----------------------------------------------------------------
sub processVPL { 
# This is originally by Piet Tutelaers <rcpt@urc.tue.nl>
   local($font) = @_;
   print "Processing $font.vpl\n" if $opt_verbose;
   open(VPL,"$font.vpl") 
    || die "cannot open VPL $font.vpl";
   open(TMPVPL, ">tmp.vpl");
   print TMPVPL "(COMMENT new FONTCHECKSUMs added)\n";
   while (<VPL>) {
      $vpl = $_;
      next if (/FONTCHECKSUM/);
      if (/FONTNAME/) {
         $offset = index($vpl, "FONTNAME");
         $offset = index($vpl, ")", $offset);
         die "[addchecksum] Expected a closing brace after FONTNAME in line:",
             "\n$vpl" if $offset == -1;
         ($fontname) =  ($vpl =~ /FONTNAME\s+(\w+)/);
         $cs = 0;
	 if (-r "$fontname.tfm")
           {
            chop($cs = `cs -o "$fontname.tfm"`);
	    print "Read $cs from $fontname.tfm\n" if $opt_verbose;
	    }
         elsif (-r "$fontname.pl") {
            $_=$fontname;
            s/8r[a-z]?$/8a/;
            $AFMfile=`kpsewhich $_.afm`;
            chop($AFMfile);
            if ($AFMfile eq "")
	       { die "No AFM file found for font $_\n"; }
            else
	    {
              $cs= &make_tfm($fontname,$AFMfile,"");
  	      print "Generated $cs from $fontname.pl\n" if $opt_verbose;
	      die "[addchecksum] $fontname: invalid checksum" unless $cs != 0;
	      }
             }
         else {
# see it exists on the system
	    $TFMfile=`kpsewhich $fontname.tfm`;
	    chop($TFMfile);
            if ($TFMfile ne "") {
              chop($cs = `cs -o "$TFMfile"`);
	      print "Read $cs from $TFMfile\n" if $opt_verbose;
             }
	    else
             { die "[addchecksum] No font for $fontname\n"; }
         }
         die "[addchecksum] cs: exit code ", ($? >>8) & 255, "\n" if $cs == 0 && $?;
         substr($vpl, $offset+1, 0) = " (FONTCHECKSUM O $cs) ";
      }
      print TMPVPL $vpl;
   }
   close(VPL); 
   close(TMPVPL);
   unlink("$font.vpl");
   rename("tmp.vpl", "$font.vpl");
   runsystem("vptovf $font.vpl $font.vf $font.tfm");
   die "[addchecksum] vptovf: exit code ", ($? >>8) & 255, "\n" if $?;
}

#-----------------------------------------------------------------

sub runTeX {
 open(TEX,">Fam_$$.tex") 
    || die ("Cannot open Fam_$$.tex");
 if ($opt_verbose)
   { print TEX "\\nonstopmode\n" ; } 
 else
   { print TEX "\\batchmode\n" ; } 
 print TEX "\\input fontinst.sty\n";
 print TEX "\\def\\SlantAmount{",$opt_slant * 1000,"}\n";
 if ($opt_narrow) { print TEX "\\fakenarrow{$opt_narrow}\n" ; }
 print TEX "\\latinfamily{$Famcode$opt_expert$famextra}{$ExtraFDcode}\n";
 print TEX "\\end\n";
 close TEX;
 runsystem("tex -ini -progname=fontinst ./Fam_$$");
}

#-----------------------------------------------------------------
sub installTeX {
local $encoding;
for (grep(/.*\.fd/,@filenames)) { 
if (! -r "$Outdir/tex/$_") { 
 if (/^ot1/) { $encoding = "ot1"; } else { $encoding="other";}
 open NEWFD,">$Outdir/tex/$_";
 open OLDFD,"$_";
 while (<OLDFD>) {
 if ($opt_lucida)
 {
s/DeclareFontShape/DeclareLucidaFontShape/;
s/^\\DeclareFontFam/\\\@ifundefined{DeclareLucidaFontShape}{\%\n\\def\\DeclareLucidaFontShape#1#2#3#4#5#6{\%\n\\DeclareFontShape{#1}{#2}{#3}{#4}{<->#5}{#6}}}{}\n\\DeclareFontFam/;
s/^   <-> //;
if (/sub /) { s/Lucida//; }
 }
 if (/endinput/ && $encoding eq "ot1" ) { 
    print NEWFD "\\DeclareFontShape{OT1}{$Famcode$opt_expert$famextra}{m}{ui}{<->ssub * $Famcode$opt_expert$famextra/m/it}{}\n"; 
    print NEWFD "\\DeclareFontShape{OT1}{$Famcode$opt_expert$famextra}{b}{ui}{<->ssub * $Famcode$opt_expert$famextra/b/it}{}\n"; 
    print NEWFD "\\endinput\n";
        }
    else { print NEWFD ; }
}
    close OLDFD;
    close NEWFD;
  }
}
# now we have to fix the silly OML and OMS files. bleeargh.
#
 if (!$opt_lucida) {
open(CAT,">$Outdir/tex/oms$Famcode$opt_expert$famextra.fd")  
    || die ("cannot open $Outdir/tex/oms$Famcode$opt_expert$famextra.fd");
print CAT <<EOFCAT;
\\ProvidesFile{oms$Famcode$opt_expert$famextra.fd}
\\DeclareFontFamily{OMS}{$Famcode$opt_expert$famextra}{\\skewchar\\font48}
\\DeclareFontShape{OMS}{$Famcode$opt_expert$famextra}{m}{n}
   {<-> ssub * cmsy/m/n}{}
\\DeclareFontShape{OMS}{$Famcode$opt_expert$famextra}{m}{it}
   {<-> ssub * cmsy/m/n}{}
\\DeclareFontShape{OMS}{$Famcode$opt_expert$famextra}{m}{sl}
   {<-> ssub * cmsy/m/n}{}
\\DeclareFontShape{OMS}{$Famcode$opt_expert$famextra}{m}{sc}
   {<-> ssub * cmsy/m/n}{}
\\DeclareFontShape{OMS}{$Famcode$opt_expert$famextra}{b}{n}
   {<-> ssub * cmsy/b/n}{}
\\DeclareFontShape{OMS}{$Famcode$opt_expert$famextra}{b}{it}
   {<-> ssub * cmsy/b/n}{}
\\DeclareFontShape{OMS}{$Famcode$opt_expert$famextra}{b}{sl}
   {<-> ssub * cmsy/b/n}{}
\\DeclareFontShape{OMS}{$Famcode$opt_expert$famextra}{b}{sc}
   {<-> ssub * cmsy/b/n}{}
\\endinput
EOFCAT
close CAT;
open (CAT,">$Outdir/tex/oml$Famcode$opt_expert$famextra.fd") 
    || die ("cannot open $Outdir/tex/oml$Famcode$opt_expert$famextra.fd");
print CAT <<EOFCAT;
\\ProvidesFile{oml$Famcode$opt_expert$famextra.fd}
\\DeclareFontFamily{OML}{$Famcode$opt_expert$famextra}{\\skewchar\\font127}
\\DeclareFontShape{OML}{$Famcode$opt_expert$famextra}{m}{n}
   {<-> ssub * cmm/m/it}{}
\\DeclareFontShape{OML}{$Famcode$opt_expert$famextra}{m}{it}
   {<-> ssub * cmm/m/it}{}
\\DeclareFontShape{OML}{$Famcode$opt_expert$famextra}{m}{sl}
   {<-> ssub * cmm/m/it}{}
\\DeclareFontShape{OML}{$Famcode$opt_expert$famextra}{m}{sc}
   {<-> ssub * cmm/m/it}{}
\\DeclareFontShape{OML}{$Famcode$opt_expert$famextra}{b}{n}
   {<-> ssub * cmm/b/it}{}
\\DeclareFontShape{OML}{$Famcode$opt_expert$famextra}{b}{it}
   {<-> ssub * cmm/b/it}{}
\\DeclareFontShape{OML}{$Famcode$opt_expert$famextra}{b}{sl}
   {<-> ssub * cmm/b/it}{}
\\DeclareFontShape{OML}{$Famcode$opt_expert$famextra}{b}{sc}
   {<-> ssub * cmm/b/it}{}
\\endinput
EOFCAT
}
&install_README;
if ($opt_nosty) { return 0; }
open(CAT,">$Outdir/tex/$opt_expert$ShortFamily.sty");
print CAT <<EOFCAT;
\\ProvidesPackage{$opt_expert$ShortFamily}[$year/$mon/$mday:
PSNFSS v.2 LaTeX package loading $Foundry $Family. S. Rahtz]
EOFCAT
print CAT "\\renewcommand{",$Type,"default}{$Famcode$opt_expert$famextra}\n";
print CAT "\\endinput\n";
close(CAT);
}

sub install_README {
open(README,">$Outdir/README");
print "Installing README in $Outdir\n"  if $opt_verbose;
print README <<EOFCAT;
This set of metric files for the $Foundry $Family font family was
created on $year/$mon/$mday by Sebastian Rahtz, his famtool package, 
using Alan Jeffrey's fontinst TeX macros, version 1.8.
It consists of :
 + tfm files for use by TeX in old TeX encoding
     and new Cork TeX encoding 
 + vf (virtual font) files for dvi drivers 
 + tfm files for the raw fonts (TeXBase1 encoded) to use with the vf files
 + .fd (font description) files for use with LaTeX
 + a file $Famcode$opt_extra$famextra.map which lists the raw font names and their
    full PostScript names. This can be added to eg the psfonts.map file
    of dvips to ensure that the driver recognizes the names as those
    of PostScript fonts
 + a dvips config file config.$Famcode$opt_extra$famextra which can be used to tell dvips
   about the new fonts if you do not want to change the default psfonts.map
   (usage: dvips -P$Famcode$opt_extra$famextra to tell dvips about the $Family fonts)
EOFCAT
#
if ($opt_nosty) { close (README); return 0; }
print README <<EOFCAT;
 + a simple LaTeX package $ShortFamily.sty to use the new font
   family as appropriate for its type (roman, sans or typewriter).

EOFCAT
close(README);
}
sub install_symbol_README {
open(README,">$Outdir/README");
print "Installing README in $Outdir\n"  if $opt_verbose;
print README <<EOFCAT;
This set of files for the $Foundry $Family font family was
created on $year/$mon/$mday by Sebastian Rahtz, his famtool package, 
using Tom Rokicki's afm2tfm. It consists of :
 + a tfm file for use by TeX 
 + .fd (font description) file for use with LaTeX
 + a file $Famcode.map which lists the font names and their
    full PostScript names. This can be added to eg the psfonts.map file
    of dvips to ensure that the driver recognizes the names as those
    of PostScript fonts
 + a dvips config file config.$Famcode which can be used to tell dvips 
   about the new fonts if you do not want to change the default 
   psfonts.map (usage: dvips -P$Famcode to tell dvips about the $Family fonts)
EOFCAT
close(README);
}
#-----------------------------------------------------------------

sub remove_duplicates {
# read a file and remove duplicates lines
   local($filename) = @_;
   print "Reading $filename to remove duplicate lines\n" if $opt_verbose;
   local %Lines;
   open (TMP,$filename) 
     || die "Cannot read $filename to remove duplicates";
   while (<TMP>) {
      $Lines{$_} = 1;
    }
   close(TMP);
   open (TMP,">$filename") 
       || die "Cannot write $filename to remove duplicates";
   foreach $l (sort keys %Lines) {
       print TMP $l;
    }
   close(TMP);
   
}
#
# remove all files corresponding to a pattern
#
sub killfiles {
    local($killpatt) = @_;
    for (grep(/$killpatt/,@filenames)) { 
        print "NOTE: removing $_\n" if ($opt_debug);
        unlink $_ ; 
    }
    &buildfilelist;
}

sub runsystem {
    local($job) = @_;
    $result=system($job);
    print "Result $result from $job\n";
}
sub IsWin32 {
    return $^O =~ 'MSWin32';
}

sub Cleanup {
if ($opt_debug) {   print "Working files are left in /tmp/Fam_$$\n";  }
else  { print "remove files from /tmp/Fam_$$\n";
        &buildfilelist;
	for (@filenames) { unlink $_; }         
	chdir($Inidir);
	rmdir("/tmp/Fam_$$") ;
	}
}
1;