line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package PDF::API2::Resource::Font; |
2
|
|
|
|
|
|
|
|
3
|
9
|
|
|
9
|
|
1089
|
use base 'PDF::API2::Resource::BaseFont'; |
|
9
|
|
|
|
|
20
|
|
|
9
|
|
|
|
|
4684
|
|
4
|
|
|
|
|
|
|
|
5
|
9
|
|
|
9
|
|
72
|
use strict; |
|
9
|
|
|
|
|
21
|
|
|
9
|
|
|
|
|
293
|
|
6
|
9
|
|
|
9
|
|
61
|
use warnings; |
|
9
|
|
|
|
|
19
|
|
|
9
|
|
|
|
|
418
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '2.044'; # VERSION |
9
|
|
|
|
|
|
|
|
10
|
9
|
|
|
9
|
|
56
|
use Encode qw(:all); |
|
9
|
|
|
|
|
19
|
|
|
9
|
|
|
|
|
2363
|
|
11
|
|
|
|
|
|
|
|
12
|
9
|
|
|
9
|
|
76
|
use PDF::API2::Util; |
|
9
|
|
|
|
|
19
|
|
|
9
|
|
|
|
|
1182
|
|
13
|
9
|
|
|
9
|
|
76
|
use PDF::API2::Basic::PDF::Utils; |
|
9
|
|
|
|
|
27
|
|
|
9
|
|
|
|
|
13575
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub encodeByData { |
16
|
53
|
|
|
53
|
0
|
216
|
my ($self, $encoding) = @_; |
17
|
53
|
|
|
|
|
194
|
my $data = $self->data(); |
18
|
|
|
|
|
|
|
|
19
|
53
|
|
|
|
|
120
|
my ($firstChar, $lastChar); |
20
|
|
|
|
|
|
|
|
21
|
53
|
100
|
|
|
|
222
|
if ($self->issymbol()) { |
22
|
5
|
|
|
|
|
18
|
$encoding = undef; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
53
|
100
|
100
|
|
|
328
|
if (defined $encoding and $encoding =~ /^uni(\d+)$/) { |
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
26
|
1
|
|
|
|
|
4
|
my $blk = $1; |
27
|
1
|
|
|
|
|
8
|
$data->{'e2u'} = [ map { $blk * 256 + $_ } (0 .. 255) ]; |
|
256
|
|
|
|
|
354
|
|
28
|
1
|
50
|
|
|
|
6
|
$data->{'e2n'} = [ map { nameByUni($_) or '.notdef' } @{$data->{'e2u'}} ]; |
|
256
|
|
|
|
|
401
|
|
|
1
|
|
|
|
|
3
|
|
29
|
1
|
|
|
|
|
13
|
$data->{'firstchar'} = 0; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
elsif (defined $encoding) { |
32
|
1
|
|
|
|
|
13
|
$data->{'e2u'} = [ unpack('U*', decode($encoding, pack('C*', 0 .. 255))) ]; |
33
|
1
|
50
|
|
|
|
88
|
$data->{'e2n'} = [ map { nameByUni($_) or '.notdef' } @{$data->{'e2u'}} ]; |
|
256
|
|
|
|
|
403
|
|
|
1
|
|
|
|
|
4
|
|
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
elsif (defined $data->{'uni'}) { |
36
|
51
|
|
|
|
|
108
|
$data->{'e2u'} = [ @{$data->{'uni'}} ]; |
|
51
|
|
|
|
|
1328
|
|
37
|
51
|
50
|
|
|
|
118
|
$data->{'e2n'} = [ map { $_ or '.notdef' } @{$data->{'char'}} ]; |
|
13056
|
|
|
|
|
22997
|
|
|
51
|
|
|
|
|
174
|
|
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
else { |
40
|
0
|
|
|
|
|
0
|
$data->{'e2u'} = [ map { uniByName($_) } @{$data->{'char'}} ]; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
41
|
0
|
0
|
|
|
|
0
|
$data->{'e2n'} = [ map { $_ or '.notdef' } @{$data->{'char'}} ]; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
53
|
|
|
|
|
567
|
$data->{'u2c'} = {}; |
45
|
53
|
|
|
|
|
165
|
$data->{'u2e'} = {}; |
46
|
53
|
|
|
|
|
180
|
$data->{'u2n'} = {}; |
47
|
53
|
|
|
|
|
132
|
$data->{'n2c'} = {}; |
48
|
53
|
|
|
|
|
128
|
$data->{'n2e'} = {}; |
49
|
53
|
|
|
|
|
127
|
$data->{'n2u'} = {}; |
50
|
|
|
|
|
|
|
|
51
|
53
|
|
|
|
|
208
|
foreach my $n (0 .. 255) { |
52
|
13568
|
|
|
|
|
18257
|
my $xchar; |
53
|
|
|
|
|
|
|
my $xuni; |
54
|
|
|
|
|
|
|
|
55
|
13568
|
|
50
|
|
|
23676
|
$xchar = $data->{'char'}->[$n] // '.notdef'; |
56
|
13568
|
|
100
|
|
|
44269
|
$data->{'n2c'}->{$xchar} //= $n; |
57
|
|
|
|
|
|
|
|
58
|
13568
|
|
50
|
|
|
23487
|
$xchar = $data->{'e2n'}->[$n] // '.notdef'; |
59
|
13568
|
|
100
|
|
|
40871
|
$data->{'n2e'}->{$xchar} //= $n; |
60
|
|
|
|
|
|
|
|
61
|
13568
|
|
100
|
|
|
43517
|
$data->{'n2u'}->{$xchar} //= $data->{'e2u'}->[$n]; |
62
|
|
|
|
|
|
|
|
63
|
13568
|
|
50
|
|
|
22959
|
$xchar = $data->{'char'}->[$n] // '.notdef'; |
64
|
13568
|
|
100
|
|
|
24433
|
$xuni = $data->{'uni'}->[$n] // 0; |
65
|
13568
|
|
100
|
|
|
23896
|
$data->{'n2u'}->{$xchar} //= $xuni; |
66
|
|
|
|
|
|
|
|
67
|
13568
|
|
100
|
|
|
49172
|
$data->{'u2c'}->{$xuni} //= $n; |
68
|
|
|
|
|
|
|
|
69
|
13568
|
|
100
|
|
|
24306
|
$xuni = $data->{'e2u'}->[$n] // 0; |
70
|
13568
|
|
100
|
|
|
41290
|
$data->{'u2e'}->{$xuni} //= $n; |
71
|
|
|
|
|
|
|
|
72
|
13568
|
|
50
|
|
|
23291
|
$xchar = $data->{'e2n'}->[$n] // '.notdef'; |
73
|
13568
|
|
66
|
|
|
41879
|
$data->{'u2n'}->{$xuni} //= $xchar; |
74
|
|
|
|
|
|
|
|
75
|
13568
|
|
50
|
|
|
23046
|
$xchar = $data->{'char'}->[$n] // '.notdef'; |
76
|
13568
|
|
100
|
|
|
24012
|
$xuni = $data->{'uni'}->[$n] // 0; |
77
|
13568
|
|
66
|
|
|
27183
|
$data->{'u2n'}->{$xuni} //= $xchar; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
53
|
|
|
|
|
347
|
my $en = PDFDict(); |
81
|
53
|
|
|
|
|
167
|
$self->{'Encoding'} = $en; |
82
|
|
|
|
|
|
|
|
83
|
53
|
|
|
|
|
184
|
$en->{'Type'} = PDFName('Encoding'); |
84
|
53
|
|
|
|
|
161
|
$en->{'BaseEncoding'} = PDFName('WinAnsiEncoding'); |
85
|
|
|
|
|
|
|
|
86
|
53
|
|
|
|
|
216
|
$en->{'Differences'} = PDFArray(PDFNum(0)); |
87
|
53
|
|
|
|
|
181
|
foreach my $n (0 .. 255) { |
88
|
13568
|
|
50
|
|
|
24714
|
my $element = ($self->glyphByEnc($n) or '.notdef'); |
89
|
13568
|
|
|
|
|
26245
|
$en->{'Differences'}->add_elements(PDFName($element)); |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
53
|
|
|
|
|
222
|
$self->{'FirstChar'} = PDFNum($data->{'firstchar'}); |
93
|
53
|
|
|
|
|
228
|
$self->{'LastChar'} = PDFNum($data->{'lastchar'}); |
94
|
|
|
|
|
|
|
|
95
|
53
|
|
|
|
|
198
|
$self->{'Widths'} = PDFArray(); |
96
|
53
|
|
|
|
|
401
|
foreach my $n ($data->{'firstchar'} .. $data->{'lastchar'}) { |
97
|
11904
|
|
|
|
|
23819
|
$self->{'Widths'}->add_elements(PDFNum($self->wxByEnc($n))); |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
53
|
|
|
|
|
216
|
return $self; |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
sub automap { |
104
|
0
|
|
|
0
|
0
|
|
my $self = shift(); |
105
|
0
|
|
|
|
|
|
my $data = $self->data(); |
106
|
|
|
|
|
|
|
|
107
|
0
|
|
|
|
|
|
my %gl = map { $_ => defineName($_) } keys %{$data->{'wx'}}; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
|
109
|
0
|
|
|
|
|
|
foreach my $n (0 .. 255) { |
110
|
0
|
|
|
|
|
|
delete $gl{$data->{'e2n'}->[$n]}; |
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
|
113
|
0
|
0
|
0
|
|
|
|
if (defined $data->{'comps'} and not $self->{'-nocomps'}) { |
114
|
0
|
|
|
|
|
|
foreach my $n (keys %{$data->{'comps'}}) { |
|
0
|
|
|
|
|
|
|
115
|
0
|
|
|
|
|
|
delete $gl{$n}; |
116
|
|
|
|
|
|
|
} |
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
|
119
|
0
|
|
|
|
|
|
my @nm = sort { $gl{$a} <=> $gl{$b} } keys %gl; |
|
0
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
|
121
|
0
|
|
|
|
|
|
my @fonts; |
122
|
0
|
|
|
|
|
|
my $count = 0; |
123
|
0
|
|
|
|
|
|
while (my @glyphs = splice(@nm, 0, 223)) { |
124
|
0
|
|
|
|
|
|
my $obj = $self->SUPER::new($self->{' apipdf'}, $self->name() . 'am' . $count); |
125
|
0
|
|
|
|
|
|
$obj->{' data'} = { %$data }; |
126
|
0
|
|
|
|
|
|
$obj->data->{'firstchar'} = 32; |
127
|
0
|
|
|
|
|
|
$obj->data->{'lastchar'} = 32 + scalar(@glyphs); |
128
|
0
|
|
|
|
|
|
push @fonts, $obj; |
129
|
0
|
|
|
|
|
|
foreach my $key (qw(Subtype BaseFont FontDescriptor)) { |
130
|
0
|
0
|
|
|
|
|
$obj->{$key} = $self->{$key} if defined $self->{$key}; |
131
|
|
|
|
|
|
|
} |
132
|
0
|
|
|
|
|
|
$obj->data->{'char'} = []; |
133
|
0
|
|
|
|
|
|
$obj->data->{'uni'} = []; |
134
|
0
|
|
|
|
|
|
foreach my $n (0 .. 31) { |
135
|
0
|
|
|
|
|
|
$obj->data->{'char'}->[$n] = '.notdef'; |
136
|
0
|
|
|
|
|
|
$obj->data->{'uni'}->[$n] = 0; |
137
|
|
|
|
|
|
|
} |
138
|
0
|
|
|
|
|
|
$obj->data->{'char'}->[32] = 'space'; |
139
|
0
|
|
|
|
|
|
$obj->data->{'uni'}->[32] = 32; |
140
|
0
|
|
|
|
|
|
foreach my $n (33 .. $obj->data->{'lastchar'}) { |
141
|
0
|
|
|
|
|
|
$obj->data->{'char'}->[$n] = $glyphs[$n - 33]; |
142
|
0
|
|
|
|
|
|
$obj->data->{'uni'}->[$n] = $gl{$glyphs[$n - 33]}; |
143
|
|
|
|
|
|
|
} |
144
|
0
|
|
|
|
|
|
foreach my $n (($obj->data->{'lastchar'} + 1) .. 255) { |
145
|
0
|
|
|
|
|
|
$obj->data->{'char'}->[$n] = '.notdef'; |
146
|
0
|
|
|
|
|
|
$obj->data->{'uni'}->[$n] = 0; |
147
|
|
|
|
|
|
|
} |
148
|
0
|
|
|
|
|
|
$obj->encodeByData(undef); |
149
|
|
|
|
|
|
|
|
150
|
0
|
|
|
|
|
|
$count++; |
151
|
|
|
|
|
|
|
} |
152
|
|
|
|
|
|
|
|
153
|
0
|
|
|
|
|
|
return @fonts; |
154
|
|
|
|
|
|
|
} |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
sub remap { |
157
|
0
|
|
|
0
|
0
|
|
my ($self, $enc) = @_; |
158
|
|
|
|
|
|
|
|
159
|
0
|
|
|
|
|
|
my $obj = $self->SUPER::new($self->{' apipdf'}, $self->name() . 'rm' . pdfkey()); |
160
|
0
|
|
|
|
|
|
$obj->{' data'} = { %{$self->data()} }; |
|
0
|
|
|
|
|
|
|
161
|
0
|
|
|
|
|
|
foreach my $key (qw(Subtype BaseFont FontDescriptor)) { |
162
|
0
|
0
|
|
|
|
|
$obj->{$key} = $self->{$key} if defined $self->{$key}; |
163
|
|
|
|
|
|
|
} |
164
|
|
|
|
|
|
|
|
165
|
0
|
|
|
|
|
|
$obj->encodeByData($enc); |
166
|
|
|
|
|
|
|
|
167
|
0
|
|
|
|
|
|
return $obj; |
168
|
|
|
|
|
|
|
} |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
1; |