3
# Copyright (c) 1998-2000
4
# Sergey A. Babkin. All rights reserved.
6
# See the full text of the license in the COPYRIGHT file.
8
# Sergey A. Babkin (sab123@hotmail.com, babkin@users.sourceforge.net)
12
# Script to transcode the Type1 disassembled font to other encoding
15
# calculation of UniqueID from old UID and encoding name
16
# we don't have unsigned integer arithmetic in Perl
17
# so we try to do at least something
24
$uid=substr($u, -6, 6);
28
for $i (split(//,$enc)) {
31
$uid+=($uid>>16) & 0xff;
35
($uid % 1000000) + 4000000;
36
#$u . substr(sprintf("%d",$uid), 0, 5);
40
printf(STDERR "Use: trans src-table dst-table <src-font >dst-font\n");
44
# tables are formatted in two columns, one row per character
47
# Read the destination table
49
open(FILE,"<".$ARGV[1])
50
or die "Unable to read $ARGV[2]\n";
57
#read the source table and build the translation table
59
open(FILE,"<".$ARGV[0])
60
or die "Unable to read $ARGV[0]\n";
63
$trans{$sl[1]}=$dst{$sl[0]};
67
# name of the encoding, for UniqueID
69
$encname =~ s|^.*\/||g;
70
$encname =~ s|\..*$||g;
72
# now read the font file, skip everything upto the encoding table
73
# we suppose that the file was autogenerated by ttf2pt1 with my patches
76
if( /^\/FontName\s+(\S+)/) {
79
if( /^\/UniqueID\s+(\S+)/) {
82
$_=sprintf("/UniqueID %u def\n", &newuid($uid, $encname));
89
if(/^StartCharMetrics/) {
95
# read the old encoding table and build the new encoding table
97
if($fontfile) { # .t1a
103
@sl=split(/\s+/,$row);
108
if($enc{$new} eq "") {
116
# print new encoding table
120
printf("dup %d %s put\n",$i,$enc{$i});
122
printf("dup %d /.notdef put\n",$i);
126
while($row=<STDIN>) {
127
if($row !~ /^C\s+(\d+)(\s*;.*)\n/) {
136
if($enc{$new} eq "") {
144
# print new encoding table
148
printf("C %d%s\n",$i,$enc{$i});
155
# now copy the rest of file
158
if( /^\/UniqueID\s+(\S+)/) {
161
$_=sprintf("/UniqueID %u def\n", &newuid($uid, $encname));