line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# RCS Status : $Id: FontInfo.pm,v 1.12 2003-10-23 14:12:27+02 jv Exp $ |
2
|
|
|
|
|
|
|
# Author : Johan Vromans |
3
|
|
|
|
|
|
|
# Created On : December 1998 |
4
|
|
|
|
|
|
|
# Last Modified By: Johan Vromans |
5
|
|
|
|
|
|
|
# Last Modified On: Thu Oct 23 14:12:25 2003 |
6
|
|
|
|
|
|
|
# Update Count : 57 |
7
|
|
|
|
|
|
|
# Status : Released |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
################ Module Preamble ################ |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
package PostScript::FontInfo; |
12
|
|
|
|
|
|
|
|
13
|
1
|
|
|
1
|
|
20608
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
30
|
|
14
|
|
|
|
|
|
|
|
15
|
1
|
|
|
1
|
|
34
|
BEGIN { require 5.005; } |
16
|
|
|
|
|
|
|
|
17
|
1
|
|
|
1
|
|
677
|
use IO qw(File); |
|
1
|
|
|
|
|
757
|
|
|
1
|
|
|
|
|
6
|
|
18
|
|
|
|
|
|
|
|
19
|
1
|
|
|
1
|
|
10592
|
use vars qw($VERSION); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
746
|
|
20
|
|
|
|
|
|
|
$VERSION = "1.05"; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub new { |
23
|
1
|
|
|
1
|
1
|
36
|
my $class = shift; |
24
|
1
|
|
|
|
|
2
|
my $font = shift; |
25
|
1
|
|
|
|
|
9
|
my (%atts) = (error => 'die', |
26
|
|
|
|
|
|
|
verbose => 0, trace => 0, debug => 0, |
27
|
|
|
|
|
|
|
@_); |
28
|
1
|
|
|
|
|
4
|
my $self = { file => $font }; |
29
|
1
|
|
|
|
|
2
|
bless $self, $class; |
30
|
|
|
|
|
|
|
|
31
|
1
|
50
|
|
|
|
3
|
return $self unless defined $font; |
32
|
|
|
|
|
|
|
|
33
|
1
|
|
|
|
|
6
|
$self->{debug} = $atts{debug}; |
34
|
1
|
|
33
|
|
|
9
|
$self->{trace} = $self->{debug} || $atts{trace}; |
35
|
1
|
|
33
|
|
|
13
|
$self->{verbose} = $self->{trace} || $atts{verbose}; |
36
|
|
|
|
|
|
|
|
37
|
1
|
|
|
|
|
5
|
my $error = lc($atts{error}); |
38
|
|
|
|
|
|
|
$self->{die} = sub { |
39
|
0
|
0
|
|
0
|
|
0
|
die(@_) if $error eq "die"; |
40
|
0
|
0
|
|
|
|
0
|
warn(@_) if $error eq "warn"; |
41
|
1
|
|
|
|
|
8
|
}; |
42
|
|
|
|
|
|
|
|
43
|
1
|
|
|
|
|
3
|
eval { |
44
|
1
|
|
|
|
|
5
|
$self->_loadinfo; |
45
|
|
|
|
|
|
|
}; |
46
|
|
|
|
|
|
|
|
47
|
1
|
50
|
|
|
|
4
|
if ( $@ ) { |
48
|
0
|
|
|
|
|
0
|
$self->_die($@); |
49
|
0
|
|
|
|
|
0
|
return undef; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
1
|
|
|
|
|
5
|
$self; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
0
|
|
|
0
|
1
|
0
|
sub FileName { my $self = shift; $self->{file}; } |
|
0
|
|
|
|
|
0
|
|
56
|
1
|
|
|
1
|
1
|
368
|
sub FontName { my $self = shift; $self->{name}; } |
|
1
|
|
|
|
|
16
|
|
57
|
1
|
|
|
1
|
1
|
3
|
sub FullName { my $self = shift; $self->{fullname};} |
|
1
|
|
|
|
|
9
|
|
58
|
0
|
|
|
0
|
1
|
0
|
sub InfoData { my $self = shift; $self->{data}; } |
|
0
|
|
|
|
|
0
|
|
59
|
1
|
|
|
1
|
1
|
2
|
sub FontFamily { my $self = shift; $self->{family}; } |
|
1
|
|
|
|
|
5
|
|
60
|
1
|
|
|
1
|
1
|
1
|
sub Version { my $self = shift; $self->{version}; } |
|
1
|
|
|
|
|
6
|
|
61
|
1
|
|
|
1
|
1
|
3
|
sub PCFileNamePrefix { my $self = shift; $self->{pcprefix}; } |
|
1
|
|
|
|
|
4
|
|
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub _loadinfo ($) { |
64
|
|
|
|
|
|
|
|
65
|
1
|
|
|
1
|
|
2
|
my ($self) = shift; |
66
|
|
|
|
|
|
|
|
67
|
1
|
|
|
|
|
2
|
my $data; # inf data |
68
|
|
|
|
|
|
|
|
69
|
1
|
|
|
|
|
2
|
eval { # so we can use die |
70
|
|
|
|
|
|
|
|
71
|
1
|
|
|
|
|
3
|
my $fn = $self->{file}; |
72
|
1
|
|
|
|
|
10
|
my $fh = new IO::File; # font file |
73
|
1
|
|
|
|
|
62
|
my $sz = -s $fn; # file size |
74
|
|
|
|
|
|
|
|
75
|
1
|
50
|
|
|
|
6
|
$fh->open ($fn) || $self->_die("$fn: $!\n"); |
76
|
1
|
50
|
|
|
|
59
|
print STDERR ("$fn: Loading INF file\n") if $self->{verbose}; |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
# Read in the inf data. |
79
|
1
|
|
|
|
|
2
|
my $len = 0; |
80
|
1
|
|
|
|
|
10
|
while ( $fh->sysread ($data, 32768, $len) > 0 ) { |
81
|
1
|
|
|
|
|
41
|
$len = length ($data); |
82
|
|
|
|
|
|
|
} |
83
|
1
|
|
|
|
|
17
|
$fh->close; |
84
|
1
|
50
|
|
|
|
24
|
print STDERR ("Read $len bytes from $fn\n") if $self->{trace}; |
85
|
1
|
50
|
|
|
|
4
|
$self->_die("$fn: Expecting $sz bytes, got $len bytes\n") unless $sz == $len; |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
# Normalise line endings. |
88
|
1
|
|
|
|
|
26
|
$data =~ s/\015\012?/\n/g; |
89
|
|
|
|
|
|
|
|
90
|
1
|
50
|
|
|
|
9
|
if ( $data !~ /^FontName\s+\(\S+\)$/m ) { |
91
|
0
|
|
|
|
|
0
|
$self->_die("$fn: Not a recognizable INF file\n"); |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
}; |
95
|
|
|
|
|
|
|
|
96
|
1
|
50
|
|
|
|
10
|
$self->{name} = $1 if $data =~ /^FontName\s+\((\S+)\)$/mi; |
97
|
1
|
50
|
|
|
|
10
|
$self->{fullname}= $1 if $data =~ /^FullName\s+\((.+?)\)$/mi; |
98
|
1
|
50
|
|
|
|
9
|
$self->{family} = $1 if $data =~ /^FamilyName\s+\((.+)\)$/mi; |
99
|
1
|
50
|
|
|
|
9
|
$self->{version} = $1 if $data =~ /^Version\s+\((.+)\)$/mi; |
100
|
1
|
50
|
|
|
|
24
|
$self->{pcprefix}= lc($1) |
101
|
|
|
|
|
|
|
if $data =~ /^PCFileNamePrefix\s+\((.+)\)$/mi; |
102
|
1
|
|
|
|
|
3
|
$self->{data} = $data; |
103
|
|
|
|
|
|
|
|
104
|
1
|
|
|
|
|
3
|
$self; |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
sub _die { |
108
|
0
|
|
|
0
|
|
|
my ($self, @msg) = @_; |
109
|
0
|
|
|
|
|
|
$self->{die}->(@msg); |
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
1; |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
__END__ |