line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package PDF::API2::Resource::CIDFont::TrueType; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
1067
|
use base 'PDF::API2::Resource::CIDFont'; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
113
|
|
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
7
|
use strict; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
23
|
|
6
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
53
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '2.044'; # VERSION |
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
7
|
use PDF::API2::Basic::PDF::Utils; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
91
|
|
11
|
1
|
|
|
1
|
|
601
|
use PDF::API2::Resource::CIDFont::TrueType::FontFile; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
43
|
|
12
|
1
|
|
|
1
|
|
7
|
use PDF::API2::Util; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
1005
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 NAME |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
PDF::API2::Resource::CIDFont::TrueType - TrueType font support |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 METHODS |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=over |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=item $font = PDF::API2::Resource::CIDFont::TrueType->new $pdf, $file, %options |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
Returns a font object. |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
Defined Options: |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
-encode ... specify fonts encoding for non-utf8 text. |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
-nosubset ... disables subsetting. |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=cut |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub new { |
35
|
0
|
|
|
0
|
1
|
|
my ($class, $pdf, $file, %opts) = @_; |
36
|
0
|
|
0
|
|
|
|
$opts{'-encode'} //= 'latin1'; |
37
|
|
|
|
|
|
|
|
38
|
0
|
|
|
|
|
|
my ($ff, $data) = PDF::API2::Resource::CIDFont::TrueType::FontFile->new($pdf, $file, %opts); |
39
|
|
|
|
|
|
|
|
40
|
0
|
0
|
|
|
|
|
$class = ref($class) if ref($class); |
41
|
0
|
|
|
|
|
|
my $self = $class->SUPER::new($pdf, $data->{'apiname'} . pdfkey() . '~' . time()); |
42
|
0
|
0
|
0
|
|
|
|
$pdf->new_obj($self) if defined($pdf) and not $self->is_obj($pdf); |
43
|
|
|
|
|
|
|
|
44
|
0
|
|
|
|
|
|
$self->{' data'} = $data; |
45
|
|
|
|
|
|
|
|
46
|
0
|
|
|
|
|
|
$self->{'BaseFont'} = PDFName($self->fontname()); |
47
|
|
|
|
|
|
|
|
48
|
0
|
|
|
|
|
|
my $des = $self->descrByData(); |
49
|
0
|
|
|
|
|
|
my $de = $self->{' de'}; |
50
|
|
|
|
|
|
|
|
51
|
0
|
|
|
|
|
|
$de->{'FontDescriptor'} = $des; |
52
|
0
|
0
|
|
|
|
|
$de->{'Subtype'} = PDFName($self->iscff() ? 'CIDFontType0' : 'CIDFontType2'); |
53
|
0
|
|
|
|
|
|
$de->{'BaseFont'} = PDFName($self->fontname()); |
54
|
0
|
|
|
|
|
|
$de->{'DW'} = PDFNum($self->missingwidth()); |
55
|
0
|
0
|
|
|
|
|
if ($opts{'embed'}) { |
56
|
0
|
0
|
|
|
|
|
$des->{$self->iscff() ? 'FontFile3' : 'FontFile2'} = $ff; |
57
|
|
|
|
|
|
|
} |
58
|
0
|
0
|
|
|
|
|
unless ($self->issymbol()) { |
59
|
0
|
|
|
|
|
|
$self->encodeByName($opts{'-encode'}); |
60
|
0
|
|
|
|
|
|
$self->data->{encode} = $opts{'-encode'}; |
61
|
0
|
|
|
|
|
|
$self->data->{decode} = 'ident'; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
0
|
0
|
|
|
|
|
if ($opts{'-nosubset'}) { |
65
|
0
|
|
|
|
|
|
$self->data->{'nosubset'} = 1; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
0
|
|
|
|
|
|
$self->{' ff'} = $ff; |
69
|
0
|
|
|
|
|
|
$pdf->new_obj($ff); |
70
|
|
|
|
|
|
|
|
71
|
0
|
0
|
|
|
|
|
$self->{'-dokern'} = 1 if $opts{'-dokern'}; |
72
|
|
|
|
|
|
|
|
73
|
0
|
|
|
|
|
|
return $self; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
0
|
|
|
0
|
0
|
|
sub fontfile { return $_[0]->{' ff'}; } |
77
|
0
|
|
|
0
|
0
|
|
sub fontobj { return $_[0]->data->{'obj'}; } |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub wxByCId { |
80
|
0
|
|
|
0
|
0
|
|
my ($self, $g) = @_; |
81
|
0
|
|
|
|
|
|
my $t = $self->fontobj->{'hmtx'}->read->{'advance'}[$g]; |
82
|
|
|
|
|
|
|
|
83
|
0
|
0
|
|
|
|
|
if (defined $t) { |
84
|
0
|
|
|
|
|
|
return int($t * 1000 / $self->data->{'upem'}); |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
else { |
87
|
0
|
|
|
|
|
|
return $self->missingwidth(); |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
sub haveKernPairs { |
92
|
0
|
|
|
0
|
0
|
|
my $self = shift(); |
93
|
0
|
|
|
|
|
|
return $self->fontfile->haveKernPairs(); |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
sub kernPairCid { |
97
|
0
|
|
|
0
|
0
|
|
my ($self, $i1, $i2) = @_; |
98
|
0
|
|
|
|
|
|
return $self->fontfile->kernPairCid($i1, $i2); |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
sub subsetByCId { |
102
|
0
|
|
|
0
|
0
|
|
my ($self, $g) = @_; |
103
|
0
|
0
|
|
|
|
|
return if $self->iscff(); |
104
|
0
|
|
|
|
|
|
return $self->fontfile->subsetByCId($g); |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
sub subvec { |
108
|
0
|
|
|
0
|
0
|
|
my ($self, $g) = @_; |
109
|
0
|
0
|
|
|
|
|
return 1 if $self->iscff(); |
110
|
0
|
|
|
|
|
|
return $self->fontfile->subvec($g); |
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
|
113
|
0
|
|
|
0
|
1
|
|
sub glyphNum { return $_[0]->fontfile->glyphNum() } |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
sub outobjdeep { |
116
|
0
|
|
|
0
|
1
|
|
my ($self, $fh, $pdf) = @_; |
117
|
|
|
|
|
|
|
|
118
|
0
|
|
|
|
|
|
my $notdefbefore = 1; |
119
|
|
|
|
|
|
|
|
120
|
0
|
|
|
|
|
|
my $wx = PDFArray(); |
121
|
0
|
|
|
|
|
|
$self->{' de'}->{'W'} = $wx; |
122
|
0
|
|
|
|
|
|
my $ml; |
123
|
|
|
|
|
|
|
|
124
|
0
|
|
|
|
|
|
foreach my $w (0 .. (scalar @{$self->data->{'g2u'}} - 1)) { |
|
0
|
|
|
|
|
|
|
125
|
0
|
0
|
0
|
|
|
|
if ($self->subvec($w) and $notdefbefore) { |
|
|
0
|
0
|
|
|
|
|
126
|
0
|
|
|
|
|
|
$notdefbefore = 0; |
127
|
0
|
|
|
|
|
|
$ml = PDFArray(); |
128
|
0
|
|
|
|
|
|
$wx->add_elements(PDFNum($w), $ml); |
129
|
0
|
|
|
|
|
|
$ml->add_elements(PDFNum($self->wxByCId($w))); |
130
|
|
|
|
|
|
|
} |
131
|
|
|
|
|
|
|
elsif ($self->subvec($w) and not $notdefbefore) { |
132
|
0
|
|
|
|
|
|
$ml->add_elements(PDFNum($self->wxByCId($w))); |
133
|
|
|
|
|
|
|
} |
134
|
|
|
|
|
|
|
else { |
135
|
0
|
|
|
|
|
|
$notdefbefore = 1; |
136
|
|
|
|
|
|
|
} |
137
|
|
|
|
|
|
|
} |
138
|
|
|
|
|
|
|
|
139
|
0
|
|
|
|
|
|
$self->SUPER::outobjdeep($fh, $pdf); |
140
|
|
|
|
|
|
|
} |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=back |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=cut |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
1; |