line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package PDF::API2::Resource::Font; |
2
|
|
|
|
|
|
|
|
3
|
9
|
|
|
9
|
|
1291
|
use base 'PDF::API2::Resource::BaseFont'; |
|
9
|
|
|
|
|
29
|
|
|
9
|
|
|
|
|
4698
|
|
4
|
|
|
|
|
|
|
|
5
|
9
|
|
|
9
|
|
81
|
use strict; |
|
9
|
|
|
|
|
26
|
|
|
9
|
|
|
|
|
337
|
|
6
|
9
|
|
|
9
|
|
58
|
use warnings; |
|
9
|
|
|
|
|
30
|
|
|
9
|
|
|
|
|
431
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '2.043'; # VERSION |
9
|
|
|
|
|
|
|
|
10
|
9
|
|
|
9
|
|
57
|
use Encode qw(:all); |
|
9
|
|
|
|
|
22
|
|
|
9
|
|
|
|
|
2453
|
|
11
|
|
|
|
|
|
|
|
12
|
9
|
|
|
9
|
|
76
|
use PDF::API2::Util; |
|
9
|
|
|
|
|
21
|
|
|
9
|
|
|
|
|
1300
|
|
13
|
9
|
|
|
9
|
|
76
|
use PDF::API2::Basic::PDF::Utils; |
|
9
|
|
|
|
|
40
|
|
|
9
|
|
|
|
|
13547
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub encodeByData { |
16
|
53
|
|
|
53
|
0
|
256
|
my ($self, $encoding) = @_; |
17
|
53
|
|
|
|
|
157
|
my $data = $self->data(); |
18
|
|
|
|
|
|
|
|
19
|
53
|
|
|
|
|
162
|
my ($firstChar, $lastChar); |
20
|
|
|
|
|
|
|
|
21
|
53
|
100
|
|
|
|
223
|
if ($self->issymbol()) { |
22
|
5
|
|
|
|
|
14
|
$encoding = undef; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
53
|
100
|
100
|
|
|
353
|
if (defined $encoding and $encoding =~ /^uni(\d+)$/) { |
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
26
|
1
|
|
|
|
|
4
|
my $blk = $1; |
27
|
1
|
|
|
|
|
4
|
$data->{'e2u'} = [ map { $blk * 256 + $_ } (0 .. 255) ]; |
|
256
|
|
|
|
|
350
|
|
28
|
1
|
50
|
|
|
|
7
|
$data->{'e2n'} = [ map { nameByUni($_) or '.notdef' } @{$data->{'e2u'}} ]; |
|
256
|
|
|
|
|
418
|
|
|
1
|
|
|
|
|
3
|
|
29
|
1
|
|
|
|
|
10
|
$data->{'firstchar'} = 0; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
elsif (defined $encoding) { |
32
|
1
|
|
|
|
|
19
|
$data->{'e2u'} = [ unpack('U*', decode($encoding, pack('C*', 0 .. 255))) ]; |
33
|
1
|
50
|
|
|
|
110
|
$data->{'e2n'} = [ map { nameByUni($_) or '.notdef' } @{$data->{'e2u'}} ]; |
|
256
|
|
|
|
|
415
|
|
|
1
|
|
|
|
|
4
|
|
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
elsif (defined $data->{'uni'}) { |
36
|
51
|
|
|
|
|
117
|
$data->{'e2u'} = [ @{$data->{'uni'}} ]; |
|
51
|
|
|
|
|
1306
|
|
37
|
51
|
50
|
|
|
|
129
|
$data->{'e2n'} = [ map { $_ or '.notdef' } @{$data->{'char'}} ]; |
|
13056
|
|
|
|
|
22317
|
|
|
51
|
|
|
|
|
172
|
|
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
|
|
|
|
|
544
|
$data->{'u2c'} = {}; |
45
|
53
|
|
|
|
|
136
|
$data->{'u2e'} = {}; |
46
|
53
|
|
|
|
|
129
|
$data->{'u2n'} = {}; |
47
|
53
|
|
|
|
|
123
|
$data->{'n2c'} = {}; |
48
|
53
|
|
|
|
|
140
|
$data->{'n2e'} = {}; |
49
|
53
|
|
|
|
|
146
|
$data->{'n2u'} = {}; |
50
|
|
|
|
|
|
|
|
51
|
53
|
|
|
|
|
542
|
foreach my $n (0 .. 255) { |
52
|
13568
|
|
|
|
|
18012
|
my $xchar; |
53
|
|
|
|
|
|
|
my $xuni; |
54
|
|
|
|
|
|
|
|
55
|
13568
|
|
50
|
|
|
22779
|
$xchar = $data->{'char'}->[$n] // '.notdef'; |
56
|
13568
|
|
100
|
|
|
44520
|
$data->{'n2c'}->{$xchar} //= $n; |
57
|
|
|
|
|
|
|
|
58
|
13568
|
|
50
|
|
|
22382
|
$xchar = $data->{'e2n'}->[$n] // '.notdef'; |
59
|
13568
|
|
100
|
|
|
39452
|
$data->{'n2e'}->{$xchar} //= $n; |
60
|
|
|
|
|
|
|
|
61
|
13568
|
|
100
|
|
|
42119
|
$data->{'n2u'}->{$xchar} //= $data->{'e2u'}->[$n]; |
62
|
|
|
|
|
|
|
|
63
|
13568
|
|
50
|
|
|
22211
|
$xchar = $data->{'char'}->[$n] // '.notdef'; |
64
|
13568
|
|
100
|
|
|
23549
|
$xuni = $data->{'uni'}->[$n] // 0; |
65
|
13568
|
|
100
|
|
|
23328
|
$data->{'n2u'}->{$xchar} //= $xuni; |
66
|
|
|
|
|
|
|
|
67
|
13568
|
|
100
|
|
|
45791
|
$data->{'u2c'}->{$xuni} //= $n; |
68
|
|
|
|
|
|
|
|
69
|
13568
|
|
100
|
|
|
23463
|
$xuni = $data->{'e2u'}->[$n] // 0; |
70
|
13568
|
|
100
|
|
|
39324
|
$data->{'u2e'}->{$xuni} //= $n; |
71
|
|
|
|
|
|
|
|
72
|
13568
|
|
50
|
|
|
22203
|
$xchar = $data->{'e2n'}->[$n] // '.notdef'; |
73
|
13568
|
|
66
|
|
|
39616
|
$data->{'u2n'}->{$xuni} //= $xchar; |
74
|
|
|
|
|
|
|
|
75
|
13568
|
|
50
|
|
|
22308
|
$xchar = $data->{'char'}->[$n] // '.notdef'; |
76
|
13568
|
|
100
|
|
|
23251
|
$xuni = $data->{'uni'}->[$n] // 0; |
77
|
13568
|
|
66
|
|
|
26091
|
$data->{'u2n'}->{$xuni} //= $xchar; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
53
|
|
|
|
|
394
|
my $en = PDFDict(); |
81
|
53
|
|
|
|
|
168
|
$self->{'Encoding'} = $en; |
82
|
|
|
|
|
|
|
|
83
|
53
|
|
|
|
|
180
|
$en->{'Type'} = PDFName('Encoding'); |
84
|
53
|
|
|
|
|
169
|
$en->{'BaseEncoding'} = PDFName('WinAnsiEncoding'); |
85
|
|
|
|
|
|
|
|
86
|
53
|
|
|
|
|
205
|
$en->{'Differences'} = PDFArray(PDFNum(0)); |
87
|
53
|
|
|
|
|
198
|
foreach my $n (0 .. 255) { |
88
|
13568
|
|
50
|
|
|
24746
|
my $element = ($self->glyphByEnc($n) or '.notdef'); |
89
|
13568
|
|
|
|
|
26102
|
$en->{'Differences'}->add_elements(PDFName($element)); |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
53
|
|
|
|
|
291
|
$self->{'FirstChar'} = PDFNum($data->{'firstchar'}); |
93
|
53
|
|
|
|
|
269
|
$self->{'LastChar'} = PDFNum($data->{'lastchar'}); |
94
|
|
|
|
|
|
|
|
95
|
53
|
|
|
|
|
213
|
$self->{'Widths'} = PDFArray(); |
96
|
53
|
|
|
|
|
420
|
foreach my $n ($data->{'firstchar'} .. $data->{'lastchar'}) { |
97
|
11904
|
|
|
|
|
23100
|
$self->{'Widths'}->add_elements(PDFNum($self->wxByEnc($n))); |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
53
|
|
|
|
|
289
|
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; |