#!/usr/bin/perl

# Written by Skip Collins <bernard.collins@jhuapl.edu>
use Cwd;
$currentdir = cwd;
$remaptmp = "/var/tmp/remaptmp";
mkdir($remaptmp, 0777);
$configfiles[0]=`kpsewhich -format="dvips config" psfonts.cm`;
$configfiles[1]=`kpsewhich -format="dvips config" psfonts.ams`;
$fontlist = "";
$i=0;
foreach $cfg (@configfiles) {
    open(INPUT,$cfg) || die "Can't open font list";
    while (<INPUT>) {
	$string = $_;
	$string =~ s/\s*\w*\s*$//;
	$fontlist[$i] = $string;
	$i++;
    }
    close(INPUT);
}
chdir($remaptmp);
foreach $i (@fontlist) {
    system("tftopl -charcode-format=octal $i $i");
    system("remap $i");
    system("vptovf $i");
    system("pltotf ai$i");
    system("mv ai$i.tfm $currentdir");
    system("mv $i.vf $currentdir");
}

#system("rm -rf $remaptmp");
