1 | #!/usr/bin/perl -w |
---|
2 | # |
---|
3 | # Copyright (c) 2002 Mike Fabian <mike.fabian@gmx.de> |
---|
4 | # |
---|
5 | # This program is free software; you can redistribute it and/or modify it |
---|
6 | # under the terms of the GNU General Public License as published by |
---|
7 | # the Free Software Foundation; either version 2, or (at your option) |
---|
8 | # any later version. |
---|
9 | # |
---|
10 | # This program is distributed in the hope that it will be useful, but |
---|
11 | # WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
13 | # General Public License for more details. |
---|
14 | |
---|
15 | use English; |
---|
16 | use Getopt::Long; |
---|
17 | |
---|
18 | sub usage { |
---|
19 | print "Usage: sfd2map [-debug|d]\n\n"; |
---|
20 | print "Converts a .sfd files in the format used by ttf2pk and ttf2tfm\n"; |
---|
21 | print "into .map files in the format expected by ttf2pt1. For example:\n\n"; |
---|
22 | print " sfd2map < UJIS.sfd > UJIS.map \n\n"; |
---|
23 | exit 1; |
---|
24 | } |
---|
25 | |
---|
26 | # Process command line options |
---|
27 | my %opt; |
---|
28 | unless (GetOptions(\%opt, |
---|
29 | '-debug|d' , \$OPT_DEBUG |
---|
30 | )) { |
---|
31 | &usage(); |
---|
32 | exit 1; |
---|
33 | } |
---|
34 | |
---|
35 | if($OPT_DEBUG) { |
---|
36 | } |
---|
37 | |
---|
38 | open (MAP, ">&STDOUT"); |
---|
39 | open (SFD, "<&STDIN"); |
---|
40 | |
---|
41 | print MAP "# generated from a .sfd file by sfd2map to make it usable with ttf2pt1\n"; |
---|
42 | print MAP "#\n"; |
---|
43 | |
---|
44 | while (<SFD>) { |
---|
45 | |
---|
46 | if ( ! ($ARG =~ /^[[:space:]]*\#/)) { # skip comment lines |
---|
47 | |
---|
48 | # handle plane numbers: |
---|
49 | if ( $ARG =~ /^([[:xdigit:]]{2})[[:space:]]*/ ) { |
---|
50 | $ARG =~ s/^([[:xdigit:]]{2})[[:space:]]*/ /; |
---|
51 | print MAP "plane $1\n"; |
---|
52 | print MAP "at 0x00\n"; |
---|
53 | } |
---|
54 | |
---|
55 | # remove continuation chars '\': |
---|
56 | $ARG =~ s/\\$//; |
---|
57 | |
---|
58 | $ARG =~ s/(0x[[:xdigit:]]{1,4})/$1,/g; |
---|
59 | # handle ranges like 0xF800_0xF8FF |
---|
60 | $ARG =~ s/(0x[[:xdigit:]]{1,4}),_/$1-/g; |
---|
61 | |
---|
62 | } |
---|
63 | |
---|
64 | print MAP $ARG; |
---|
65 | |
---|
66 | } |
---|
67 | |
---|
68 | |
---|