line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package PDF::API2::Resource::Font; |
2
|
|
|
|
|
|
|
|
3
|
9
|
|
|
9
|
|
1038
|
use base 'PDF::API2::Resource::BaseFont'; |
|
9
|
|
|
|
|
17
|
|
|
9
|
|
|
|
|
4341
|
|
4
|
|
|
|
|
|
|
|
5
|
9
|
|
|
9
|
|
63
|
use strict; |
|
9
|
|
|
|
|
21
|
|
|
9
|
|
|
|
|
259
|
|
6
|
9
|
|
|
9
|
|
51
|
use warnings; |
|
9
|
|
|
|
|
17
|
|
|
9
|
|
|
|
|
371
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '2.045'; # VERSION |
9
|
|
|
|
|
|
|
|
10
|
9
|
|
|
9
|
|
104
|
use Encode qw(:all); |
|
9
|
|
|
|
|
21
|
|
|
9
|
|
|
|
|
2237
|
|
11
|
|
|
|
|
|
|
|
12
|
9
|
|
|
9
|
|
69
|
use PDF::API2::Util; |
|
9
|
|
|
|
|
27
|
|
|
9
|
|
|
|
|
1079
|
|
13
|
9
|
|
|
9
|
|
71
|
use PDF::API2::Basic::PDF::Utils; |
|
9
|
|
|
|
|
28
|
|
|
9
|
|
|
|
|
13000
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub encodeByData { |
16
|
53
|
|
|
53
|
0
|
199
|
my ($self, $encoding) = @_; |
17
|
53
|
|
|
|
|
175
|
my $data = $self->data(); |
18
|
|
|
|
|
|
|
|
19
|
53
|
|
|
|
|
117
|
my ($firstChar, $lastChar); |
20
|
|
|
|
|
|
|
|
21
|
53
|
100
|
|
|
|
176
|
if ($self->issymbol()) { |
22
|
5
|
|
|
|
|
16
|
$encoding = undef; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
53
|
100
|
100
|
|
|
317
|
if (defined $encoding and $encoding =~ /^uni(\d+)$/) { |
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
26
|
1
|
|
|
|
|
3
|
my $blk = $1; |
27
|
1
|
|
|
|
|
4
|
$data->{'e2u'} = [ map { $blk * 256 + $_ } (0 .. 255) ]; |
|
256
|
|
|
|
|
286
|
|
28
|
1
|
50
|
|
|
|
5
|
$data->{'e2n'} = [ map { nameByUni($_) or '.notdef' } @{$data->{'e2u'}} ]; |
|
256
|
|
|
|
|
321
|
|
|
1
|
|
|
|
|
3
|
|
29
|
1
|
|
|
|
|
9
|
$data->{'firstchar'} = 0; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
elsif (defined $encoding) { |
32
|
1
|
|
|
|
|
14
|
$data->{'e2u'} = [ unpack('U*', decode($encoding, pack('C*', 0 .. 255))) ]; |
33
|
1
|
50
|
|
|
|
71
|
$data->{'e2n'} = [ map { nameByUni($_) or '.notdef' } @{$data->{'e2u'}} ]; |
|
256
|
|
|
|
|
305
|
|
|
1
|
|
|
|
|
3
|
|
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
elsif (defined $data->{'uni'}) { |
36
|
51
|
|
|
|
|
101
|
$data->{'e2u'} = [ @{$data->{'uni'}} ]; |
|
51
|
|
|
|
|
1289
|
|
37
|
51
|
50
|
|
|
|
114
|
$data->{'e2n'} = [ map { $_ or '.notdef' } @{$data->{'char'}} ]; |
|
13056
|
|
|
|
|
23901
|
|
|
51
|
|
|
|
|
171
|
|
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
|
|
|
|
|
545
|
$data->{'u2c'} = {}; |
45
|
53
|
|
|
|
|
145
|
$data->{'u2e'} = {}; |
46
|
53
|
|
|
|
|
157
|
$data->{'u2n'} = {}; |
47
|
53
|
|
|
|
|
125
|
$data->{'n2c'} = {}; |
48
|
53
|
|
|
|
|
125
|
$data->{'n2e'} = {}; |
49
|
53
|
|
|
|
|
141
|
$data->{'n2u'} = {}; |
50
|
|
|
|
|
|
|
|
51
|
53
|
|
|
|
|
189
|
foreach my $n (0 .. 255) { |
52
|
13568
|
|
|
|
|
18050
|
my $xchar; |
53
|
|
|
|
|
|
|
my $xuni; |
54
|
|
|
|
|
|
|
|
55
|
13568
|
|
50
|
|
|
24363
|
$xchar = $data->{'char'}->[$n] // '.notdef'; |
56
|
13568
|
|
100
|
|
|
45168
|
$data->{'n2c'}->{$xchar} //= $n; |
57
|
|
|
|
|
|
|
|
58
|
13568
|
|
50
|
|
|
24457
|
$xchar = $data->{'e2n'}->[$n] // '.notdef'; |
59
|
13568
|
|
100
|
|
|
42322
|
$data->{'n2e'}->{$xchar} //= $n; |
60
|
|
|
|
|
|
|
|
61
|
13568
|
|
100
|
|
|
45175
|
$data->{'n2u'}->{$xchar} //= $data->{'e2u'}->[$n]; |
62
|
|
|
|
|
|
|
|
63
|
13568
|
|
50
|
|
|
23828
|
$xchar = $data->{'char'}->[$n] // '.notdef'; |
64
|
13568
|
|
100
|
|
|
25116
|
$xuni = $data->{'uni'}->[$n] // 0; |
65
|
13568
|
|
100
|
|
|
24685
|
$data->{'n2u'}->{$xchar} //= $xuni; |
66
|
|
|
|
|
|
|
|
67
|
13568
|
|
100
|
|
|
46469
|
$data->{'u2c'}->{$xuni} //= $n; |
68
|
|
|
|
|
|
|
|
69
|
13568
|
|
100
|
|
|
25340
|
$xuni = $data->{'e2u'}->[$n] // 0; |
70
|
13568
|
|
100
|
|
|
42016
|
$data->{'u2e'}->{$xuni} //= $n; |
71
|
|
|
|
|
|
|
|
72
|
13568
|
|
50
|
|
|
24304
|
$xchar = $data->{'e2n'}->[$n] // '.notdef'; |
73
|
13568
|
|
66
|
|
|
42536
|
$data->{'u2n'}->{$xuni} //= $xchar; |
74
|
|
|
|
|
|
|
|
75
|
13568
|
|
50
|
|
|
23835
|
$xchar = $data->{'char'}->[$n] // '.notdef'; |
76
|
13568
|
|
100
|
|
|
24845
|
$xuni = $data->{'uni'}->[$n] // 0; |
77
|
13568
|
|
66
|
|
|
26537
|
$data->{'u2n'}->{$xuni} //= $xchar; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
53
|
|
|
|
|
265
|
my $en = PDFDict(); |
81
|
53
|
|
|
|
|
141
|
$self->{'Encoding'} = $en; |
82
|
|
|
|
|
|
|
|
83
|
53
|
|
|
|
|
167
|
$en->{'Type'} = PDFName('Encoding'); |
84
|
53
|
|
|
|
|
174
|
$en->{'BaseEncoding'} = PDFName('WinAnsiEncoding'); |
85
|
|
|
|
|
|
|
|
86
|
53
|
|
|
|
|
170
|
$en->{'Differences'} = PDFArray(PDFNum(0)); |
87
|
53
|
|
|
|
|
171
|
foreach my $n (0 .. 255) { |
88
|
13568
|
|
50
|
|
|
24803
|
my $element = ($self->glyphByEnc($n) or '.notdef'); |
89
|
13568
|
|
|
|
|
27449
|
$en->{'Differences'}->add_elements(PDFName($element)); |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
53
|
|
|
|
|
236
|
$self->{'FirstChar'} = PDFNum($data->{'firstchar'}); |
93
|
53
|
|
|
|
|
227
|
$self->{'LastChar'} = PDFNum($data->{'lastchar'}); |
94
|
|
|
|
|
|
|
|
95
|
53
|
|
|
|
|
182
|
$self->{'Widths'} = PDFArray(); |
96
|
53
|
|
|
|
|
331
|
foreach my $n ($data->{'firstchar'} .. $data->{'lastchar'}) { |
97
|
11904
|
|
|
|
|
24431
|
$self->{'Widths'}->add_elements(PDFNum($self->wxByEnc($n))); |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
53
|
|
|
|
|
224
|
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; |