summaryrefslogtreecommitdiff
path: root/fonts/psfonts/corelpak/contrib/translate-font.pl,v
blob: aeb723c2e19e10f7f8299d524d52e35604b0742e (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
head	1.3;
access;
symbols;
locks; strict;
comment	@# @;


1.3
date	99.01.12.15.52.33;	author tinne;	state Exp;
branches;
next	1.2;

1.2
date	99.01.08.11.30.25;	author tinne;	state Exp;
branches;
next	1.1;

1.1
date	99.01.08.09.13.53;	author tinne;	state Exp;
branches;
next	;


desc
@@


1.3
log
@Added Shorthelp, use some more perl modules but shell commands.
@
text
@#!/app/unido-inf/sun4_55/perl/5.004.03/bin/perl

die "Syntax: $0 pattern [suffix]\n" if ($#ARGV == -1 || $#ARGV > 1);

use Cwd qw/cwd/;
use File::Copy qw/cp/;
use File::Basename qw(dirname);

$destination=cwd();
$prgdir = dirname $0;

$tblfile = $prgdir . "/transtabl";
$mntfile = $prgdir . "/mountpoint";

if (open CDMNT, $mntfile) {
    $cd = <CDMNT>;
    chop $cd;
    close CDMNT;
} else {
    print "Please enter a mountpoint (or device letter) for the Corel CD.\n: ";
    $cd = <STDIN>;
    chop $cd;
    die "No such directory: $cd.\n" unless -d $cd;
    system "echo $cd > $mntfile";
}
$fontdir="$cd/fonts/type1";

open TBL, $tblfile or die "$tblfile - $!";
while ($entry = <TBL>) {
    next if length($entry) == 1 or $entry =~ /^#/;

    ($key, $name) = split /\s+/, $entry;
#    print "Translation of $key is $name.\n";
    @@translation{$key} = $name;
}
close TBL;

$searchname=$ARGV[0];
$firstchar=substr $searchname, 0, 1;
$firstchar =~ /[a-z]/ or die "$searchname doesn't start with letter.\n";

chdir "$fontdir/$firstchar" or die "cannot cd to $fontdir/$firstchar.\n";

@@files = glob $searchname;

$justscan = not ($suffix = $ARGV[1]);
print "Obtaining .$suffix-suffixed files.\n" unless $justscan;

foreach $file (@@files) {
    next if ($file !~ m/pfb$/);
    $head = `strings $file | head -1`;
    (undef, $name, undef) = split " ", $head;
    print "»$file«:", " " x (15 - length $file), "$name\n";
}
 
exit if $justscan;
 
foreach $file (@@files) {
    
    next if ($file !~ /$suffix$/);

    ($rawfile) = split /.$suffix$/, $file;
    if (not defined $translation{$rawfile}) {
	print "»$file«:", " " x (15 - length $file),
	    "Translation ($rawfile) unknown, skipping.\n";
	next;
    }
    $destfile = "$translation{$rawfile}.$suffix";
    print "Copying $file to $destfile.\n";
    cp $file, "$destination/$destfile";
}
@


1.2
log
@added dos specific comment.
@
text
@d3 1
a3 1
use File::Copy "cp";
d5 6
a10 2
$cwd=`pwd`; chop $cwd;
$prgdir = `dirname $0`; chop $prgdir;
d70 1
a70 1
    cp $file, "$cwd/$destfile";
@


1.1
log
@Initial revision
@
text
@d16 1
a16 1
    print "Please enter a mountpoint for the Corel CD.\n: ";
@