API2/Resource/BaseFont.pm

filter: Statementstmt 66.5% 161 / 242 Branchbran 42.4% 28 / 66 Conditioncond 41.6% 40 / 96 MC/DCmcdc 15.3% 8 / 52 Subroutinesub 62.5% 35 / 56 Podpod 89.8% 44 / 49 totaltotal 56.3% 316 / 561 SCAR 63.0
CC
76
Cov
57%
textByStrKern
90.0
descrByData
25.3
wxByUni
20.0
CRAP 545.5
« API2/Resource/XObject/Image/PNM.pm ↑ Summary API2/Basic/PDF/Pages.pm »
1 package PDF::API2::Resource::BaseFont;
2  
3 10 ▶use base 'PDF::API2::Resource';
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 10 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 10 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 10 our $VERSION = '2.044'; # VERSION
9  
10 10 ▶use Compress::Zlib;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 10 ▶use PDF::API2::Basic::PDF::Utils;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 10 ▶use PDF::API2::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 10 ▶use Scalar::Util qw(weaken);
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 =head1 NAME
16  
17 PDF::API2::Resource::BaseFont - Base class for font resources
18  
19 =head1 METHODS
20  
21 =over
22  
23 =item $font = PDF::API2::Resource::BaseFont->new($pdf, $name)
24  
25 Return a font resource object.
26  
27 =cut
28  
29 sub new {
30 54 ▶ my ($class, $pdf, $name) = @_;
Subroutine new: called CC=3 SCAR=11.1
Pod documented
31 54 my $self;
32  
33 54 ▶ $class = ref($class) if ref($class);
Branch: 1 branch
BranchTrueFalseTotal
if ref $class 0 54 54
34 54 $self = $class->SUPER::new($pdf, $name);
35  
36 54 ▶ $pdf->new_obj($self) unless $self->is_obj($pdf);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->is_obj($pdf) 0 54 54
37  
38 54 $self->{'Type'} = PDFName('Font');
39  
40 54 $self->{' apipdf'} = $pdf;
41 54 weaken $self->{' apipdf'};
42 54 return $self;
43 }
44  
45 41284 ▶sub data { return $_[0]->{' data'}; }
Subroutine data: called CC=1 SCAR=0.0
Pod undocumented
46  
47 =item $descriptor = $font->descrByData()
48  
49 Return the font's FontDescriptor key structure based on the font's data.
50  
51 =cut
52  
53 sub descrByData {
54 16 ▶ my $self = shift();
Subroutine descrByData: called CC=21 SCAR=32.3
Pod documented
55  
56 16 my $descriptor = PDFDict();
57 16 $self->{' apipdf'}->new_obj($descriptor);
58  
59 16 $descriptor->{'Type'} = PDFName('FontDescriptor');
60 16 $descriptor->{'FontName'} = PDFName($self->fontname());
61  
62 16 ▶ my @box = map { PDFNum($_ || 0) } $self->fontbbox();
Condition100%2/2
$_ || 0
l!l
631
MC/DC100%1/1
$_ || 0
$_
Truth table100%2/2
A
A= $_
Aresult
11
00
63 16 $descriptor->{'FontBBox'} = PDFArray(@box);
64  
65 16 ▶ $descriptor->{'Ascent'} = PDFNum($self->ascender() || 0);
Condition50%1/2
$self->ascender || 0
l!l
160
MC/DC0%0/1
$self->ascender || 0
$self->ascender
Truth table50%1/2
A
A= $self->ascender
Aresult
11
00
66 16 ▶ $descriptor->{'Descent'} = PDFNum($self->descender() || 0);
Condition50%1/2
$self->descender || 0
l!l
160
MC/DC0%0/1
$self->descender || 0
$self->descender
Truth table50%1/2
A
A= $self->descender
Aresult
11
00
67 16 ▶ $descriptor->{'ItalicAngle'} = PDFNum($self->italicangle() || 0.0);
Condition100%2/2
$self->italicangle || 0.0
l!l
610
MC/DC100%1/1
$self->italicangle || 0.0
$self->italicangle
Truth table100%2/2
A
A= $self->italicangle
Aresult
11
00
68 16 ▶ $descriptor->{'XHeight'} = PDFNum($self->xheight() || (($self->fontbbox())[3] * 0.5) || 500);
Condition40%2/5
$self->xheight || ($self->fontbbox)[3] * 0.5 || 500
l!l
160
$self->xheight or ($self->fontbbox)[3] * "0.5"
l!l&&r!l&&!r
1600
MC/DC0%0/2
$self->xheight || ($self->fontbbox)[3] * 0.5 || 500
$self->xheight ($self->fontbbox)[3] * "0.5"
Truth table33%1/3
A or B
A= $self->xheightB= ($self->fontbbox)[3] * "0.5"
ABresult
1X1
011
000
69 16 ▶ $descriptor->{'CapHeight'} = PDFNum($self->capheight() || ($self->fontbbox())[3] || 800);
Condition40%2/5
$self->capheight || ($self->fontbbox)[3] || 800
l!l
160
$self->capheight or ($self->fontbbox)[3]
l!l&&r!l&&!r
1600
MC/DC0%0/2
$self->capheight || ($self->fontbbox)[3] || 800
$self->capheight ($self->fontbbox)[3]
Truth table33%1/3
A or B
A= $self->capheightB= ($self->fontbbox)[3]
ABresult
1X1
011
000
70 16 ▶ $descriptor->{'StemV'} = PDFNum($self->stemv() || 0);
Condition50%1/2
$self->stemv || 0
l!l
016
MC/DC0%0/1
$self->stemv || 0
$self->stemv
Truth table50%1/2
A
A= $self->stemv
Aresult
11
00
71 16 ▶ $descriptor->{'StemH'} = PDFNum($self->stemh() || 0);
Condition50%1/2
$self->stemh || 0
l!l
016
MC/DC0%0/1
$self->stemh || 0
$self->stemh
Truth table50%1/2
A
A= $self->stemh
Aresult
11
00
72 16 ▶ $descriptor->{'AvgWidth'} = PDFNum($self->avgwidth() || 300);
Condition50%1/2
$self->avgwidth || 300
l!l
160
MC/DC0%0/1
$self->avgwidth || 300
$self->avgwidth
Truth table50%1/2
A
A= $self->avgwidth
Aresult
11
00
73 16 ▶ $descriptor->{'MissingWidth'} = PDFNum($self->missingwidth() || 300);
Condition100%2/2
$self->missingwidth || 300
l!l
115
MC/DC100%1/1
$self->missingwidth || 300
$self->missingwidth
Truth table100%2/2
A
A= $self->missingwidth
Aresult
11
00
74 16 ▶ $descriptor->{'MaxWidth'} = PDFNum($self->maxwidth() || $self->missingwidth() || ($self->fontbbox())[2]);
Condition66%4/6
$self->maxwidth || $self->missingwidth || ($self->fontbbox)[2]
l!l&&r!l&&!r
1150
$self->maxwidth or $self->missingwidth
l!l&&r!l&&!r
1015
MC/DC0%0/3
$self->maxwidth || $self->missingwidth || ($self->fontbbox)[2]
$self->maxwidth $self->missingwidth ($self->fontbbox)[2]
Truth table50%2/4
A or B || C
A= $self->maxwidthB= $self->missingwidthC= ($self->fontbbox)[2]
ABCresult
1XX1
01X1
0011
0000
75 16 ▶ $descriptor->{'Flags'} = PDFNum($self->flags() || 0) unless $self->data->{'iscore'};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->data->{"iscore"} 16 0 16
Condition50%1/2
$self->flags || 0
l!l
160
MC/DC0%0/1
$self->flags || 0
$self->flags
Truth table50%1/2
A
A= $self->flags
Aresult
11
00
76 16 ▶ if (defined $self->data->{'panose'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->data->{"panose"}) 1 15 16
77 1 $descriptor->{'Style'} = PDFDict();
78 1 $descriptor->{'Style'}->{'Panose'} = PDFStrHex($self->data->{'panose'});
79 }
80 16 ▶ $descriptor->{'FontFamily'} = PDFStr($self->data->{'fontfamily'}) if defined $self->data->{'fontfamily'};
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->data->{"fontfamily"} 1 15 16
81 16 ▶ $descriptor->{'FontWeight'} = PDFNum($self->data->{'fontweight'}) if defined $self->data->{'fontweight'};
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->data->{"fontweight"} 1 15 16
82 16 ▶ $descriptor->{'FontStretch'} = PDFName($self->data->{'fontstretch'}) if defined $self->data->{'fontstretch'};
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->data->{"fontstretch"} 1 15 16
83  
84 16 return $descriptor;
85 }
86  
87 sub tounicodemap {
88 1 ▶ my $self = shift();
Subroutine tounicodemap: called CC=11 SCAR=29.3
Pod undocumented
89  
90 1 ▶ return $self if defined $self->{'ToUnicode'};
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"ToUnicode"} 0 1 1
91  
92 1 my $stream = qq|\%\% Custom\n\%\% CMap\n\%\%\n/CIDInit /ProcSet findresource begin\n|;
93 1 $stream .= qq|12 dict begin begincmap\n|;
94 1 $stream .= qq|/CIDSystemInfo <<\n|;
95 1 $stream .= sprintf(qq| /Registry (%s)\n|, $self->name());
96 1 $stream .= qq| /Ordering (XYZ)\n|;
97 1 $stream .= qq| /Supplement 0\n|;
98 1 $stream .= qq|>> def\n|;
99 1 $stream .= sprintf(qq|/CMapName /pdfapi2-%s+0 def\n|, $self->name());
100 1 ▶ if ($self->can('uniByCId') and $self->can('glyphNum')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->can('uniByCId') and $self->can('glyphNum')) { } 0 1 1
Condition33%1/3
$self->can("uniByCId") and $self->can("glyphNum")
!ll&&!rl&&r
100
MC/DC0%0/2
$self->can("uniByCId") and $self->can("glyphNum")
$self->can("uniByCId") $self->can("glyphNum")
Truth table33%1/3
A and B
A= $self->can("uniByCId")B= $self->can("glyphNum")
ABresult
0X0
100
111
101 # this is a type0 font
102 0 $stream .= sprintf(qq|1 begincodespacerange <0000> <%04X> endcodespacerange\n|, $self->glyphNum() - 1);
103 0 ▶ for (my $j = 0; $j < $self->glyphNum(); $j++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($j < $self->glyphNum) 0 0 0
104 0 ▶ my $i = $self->glyphNum() - $j > 100 ? 100 : $self->glyphNum() - $j;
Branch: 1 branch
BranchTrueFalseTotal
$self->glyphNum - $j > 100 ? : 0 0 0
105 0 ▶ if ($j == 0) {
Branch: 2 branches
BranchTrueFalseTotal
if ($j == 0) { } 0 0 0
elsif ($j % 100 == 0) { } 0 0 0
106 0 $stream .= qq|$i beginbfrange\n|;
107 }
108 elsif ($j % 100 == 0) {
109 0 $stream .= qq|endbfrange\n|;
110 0 $stream .= qq|$i beginbfrange\n|;
111 }
112  
113 # Default to 0000 if uniByCId returns undef in order to match
114 # previous behavior minus an uninitialized value warning. It's
115 # worth looking into what should be happening here, since this may
116 # not be the correct behavior.
117 0 ▶ $stream .= sprintf(qq|<%04x> <%04x> <%04x>\n|, $j, $j, ($self->uniByCId($j) // 0));
Condition0%0/2
$self->uniByCId($j) // 0
l!l
00
MC/DC0%0/1
$self->uniByCId($j) // 0
$self->uniByCId($j)
Truth table0%0/2
A
A= $self->uniByCId($j)
Aresult
11
00
118 }
119 0 $stream .= "endbfrange\n";
120 }
121 else {
122 # everything else is a single byte font
123 1 $stream .= qq|1 begincodespacerange\n<00> <FF>\nendcodespacerange\n|;
124 1 $stream .= qq|256 beginbfchar\n|;
125 1 ▶ for (my $j = 0; $j < 256; $j++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($j < 256) 256 1 257
126 256 ▶ $stream .= sprintf(qq|<%02X> <%04X>\n|, $j, $self->uniByEnc($j) // 0);
Condition50%1/2
$self->uniByEnc($j) // 0
l!l
2560
MC/DC0%0/1
$self->uniByEnc($j) // 0
$self->uniByEnc($j)
Truth table50%1/2
A
A= $self->uniByEnc($j)
Aresult
11
00
127 }
128 1 $stream .= qq|endbfchar\n|;
129 }
130 1 $stream .= qq|endcmap CMapName currendict /CMap defineresource pop end end\n|;
131  
132 1 my $cmap = PDFDict();
133 1 $cmap->{'Type'} = PDFName('CMap');
134 1 $cmap->{'CMapName'} = PDFName(sprintf(qq|pdfapi2-%s+0|, $self->name()));
135 1 $cmap->{'CIDSystemInfo'} = PDFDict();
136 1 $cmap->{'CIDSystemInfo'}->{'Registry'} = PDFStr($self->name());
137 1 $cmap->{'CIDSystemInfo'}->{'Ordering'} = PDFStr('XYZ');
138 1 $cmap->{'CIDSystemInfo'}->{'Supplement'} = PDFNum(0);
139  
140 1 $self->{' apipdf'}->new_obj($cmap);
141 1 $cmap->{' nofilt'} = 1;
142 1 $cmap->{' stream'} = Compress::Zlib::compress($stream);
143 1 $cmap->{'Filter'} = PDFArray(PDFName('FlateDecode'));
144 1 $self->{'ToUnicode'} = $cmap;
145  
146 1 return $self;
147 }
148  
149 =back
150  
151 =head1 FONT-MANAGEMENT RELATED METHODS
152  
153 =over
154  
155 =item $name = $font->fontname()
156  
157 Return the font's name (a.k.a. display name).
158  
159 =cut
160  
161 71 ▶sub fontname { return $_[0]->data->{'fontname'}; }
Subroutine fontname: called CC=1 SCAR=0.0
Pod documented
162  
163 =item $name = $font->altname()
164  
165 Return the font's alternative name (a.k.a. Windows name for a postscript font).
166  
167 =cut
168  
169 0 ▶sub altname { return $_[0]->data->{'altname'}; }
Subroutine altname: not called CC=1 SCAR=6.9
Pod documented
170  
171 =item $name = $font->subname()
172  
173 Return the font's subname (a.k.a. font variant, schriftschnitt).
174  
175 =cut
176  
177 0 ▶sub subname { return $_[0]->data->{'subname'}; }
Subroutine subname: not called CC=1 SCAR=6.9
Pod documented
178  
179 =item $name = $font->apiname()
180  
181 Return the font's name to be used internally (should be equal to $font->name()).
182  
183 =cut
184  
185 0 ▶sub apiname { return $_[0]->data->{'apiname'}; }
Subroutine apiname: not called CC=1 SCAR=6.9
Pod documented
186  
187 =item $issymbol = $font->issymbol()
188  
189 Return the font's symbol flag.
190  
191 =cut
192  
193 77 ▶sub issymbol { return $_[0]->data->{'issymbol'}; }
Subroutine issymbol: called CC=1 SCAR=0.0
Pod documented
194  
195 =item $iscff = $font->iscff()
196  
197 Return the font's Compact Font Format flag.
198  
199 =cut
200  
201 0 ▶sub iscff { return $_[0]->data->{'iscff'}; }
Subroutine iscff: not called CC=1 SCAR=6.9
Pod documented
202  
203 =back
204  
205 =head1 TYPOGRAPHY RELATED METHODS
206  
207 =over
208  
209 =item ($llx, $lly, $urx, $ury) = $font->fontbbox()
210  
211 Return the font's bounding box.
212  
213 =cut
214  
215 31 ▶sub fontbbox { return @{$_[0]->data->{'fontbbox'}}; }
Subroutine fontbbox: called CC=1 SCAR=0.0
Pod documented
216  
217 =item $capheight = $font->capheight()
218  
219 Return the font's capheight value.
220  
221 =cut
222  
223 16 ▶sub capheight { return $_[0]->data->{'capheight'}; }
Subroutine capheight: called CC=1 SCAR=0.0
Pod documented
224  
225 =item $xheight = $font->xheight()
226  
227 Return the font's xheight value.
228  
229 =cut
230  
231 16 ▶sub xheight { return $_[0]->data->{'xheight'}; }
Subroutine xheight: called CC=1 SCAR=0.0
Pod documented
232  
233 =item $missingwidth = $font->missingwidth()
234  
235 Return the font's missingwidth value.
236  
237 =cut
238  
239 467 ▶sub missingwidth { return $_[0]->data->{'missingwidth'}; }
Subroutine missingwidth: called CC=1 SCAR=0.0
Pod documented
240  
241 =item $maxwidth = $font->maxwidth()
242  
243 Return the font's maxwidth value.
244  
245 =cut
246  
247 16 ▶sub maxwidth { return $_[0]->data->{'maxwidth'}; }
Subroutine maxwidth: called CC=1 SCAR=0.0
Pod documented
248  
249 =item $avgwidth = $font->avgwidth()
250  
251 Return the font's avgwidth value.
252  
253 =cut
254  
255 sub avgwidth {
256 16 ▶ my $self = shift();
Subroutine avgwidth: called CC=2 SCAR=7.4
Pod documented
257 16 my $aw = $self->data->{'avgwidth'};
258 16 ▶ $aw ||= ((
Condition33%1/3
$aw ||= ($self->wxByGlyph("a") * 64 + $self->wxByGlyph("b") * 14 + $self->wxByGlyph("c") * 27 + $self->wxByGlyph("d") * 35 + $self->wxByGlyph("e") * 100 + $self->wxByGlyph("f") * 20 + $self->wxByGlyph("g") * 14 + $self->wxByGlyph("h") * 42 + $self->wxByGlyph("i") * 63 + $self->wxByGlyph("j") * 3 + $self->wxByGlyph("k") * 6 + $self->wxByGlyph("l") * 35 + $self->wxByGlyph("m") * 20 + $self->wxByGlyph("n") * 56 + $self->wxByGlyph("o") * 56 + $self->wxByGlyph("p") * 17 + $self->wxByGlyph("q") * 4 + $self->wxByGlyph("r") * 49 + $self->wxByGlyph("s") * 56 + $self->wxByGlyph("t") * 71 + $self->wxByGlyph("u") * 31 + $self->wxByGlyph("v") * 10 + $self->wxByGlyph("w") * 18 + $self->wxByGlyph("x") * 3 + $self->wxByGlyph("y") * 18 + $self->wxByGlyph("z") * 2 + $self->wxByGlyph("A") * 64 + $self->wxByGlyph("B") * 14 + $self->wxByGlyph("C") * 27 + $self->wxByGlyph("D") * 35 + $self->wxByGlyph("E") * 100 + $self->wxByGlyph("F") * 20 + $self->wxByGlyph("G") * 14 + $self->wxByGlyph("H") * 42 + $self->wxByGlyph("I") * 63 + $self->wxByGlyph("J") * 3 + $self->wxByGlyph("K") * 6 + $self->wxByGlyph("L") * 35 + $self->wxByGlyph("M") * 20 + $self->wxByGlyph("N") * 56 + $self->wxByGlyph("O") * 56 + $self->wxByGlyph("P") * 17 + $self->wxByGlyph("Q") * 4 + $self->wxByGlyph("R") * 49 + $self->wxByGlyph("S") * 56 + $self->wxByGlyph("T") * 71 + $self->wxByGlyph("U") * 31 + $self->wxByGlyph("V") * 10 + $self->wxByGlyph("W") * 18 + $self->wxByGlyph("X") * 3 + $self->wxByGlyph("Y") * 18 + $self->wxByGlyph("Z") * 2 + $self->wxByGlyph("space") * 332) / 2000
l!l&&r!l&&!r
0160
MC/DC0%0/2
$aw ||= ($self->wxByGlyph("a") * 64 + $self->wxByGlyph("b") * 14 + $self->wxByGlyph("c") * 27 + $self->wxByGlyph("d") * 35 + $self->wxByGlyph("e") * 100 + $self->wxByGlyph("f") * 20 + $self->wxByGlyph("g") * 14 + $self->wxByGlyph("h") * 42 + $self->wxByGlyph("i") * 63 + $self->wxByGlyph("j") * 3 + $self->wxByGlyph("k") * 6 + $self->wxByGlyph("l") * 35 + $self->wxByGlyph("m") * 20 + $self->wxByGlyph("n") * 56 + $self->wxByGlyph("o") * 56 + $self->wxByGlyph("p") * 17 + $self->wxByGlyph("q") * 4 + $self->wxByGlyph("r") * 49 + $self->wxByGlyph("s") * 56 + $self->wxByGlyph("t") * 71 + $self->wxByGlyph("u") * 31 + $self->wxByGlyph("v") * 10 + $self->wxByGlyph("w") * 18 + $self->wxByGlyph("x") * 3 + $self->wxByGlyph("y") * 18 + $self->wxByGlyph("z") * 2 + $self->wxByGlyph("A") * 64 + $self->wxByGlyph("B") * 14 + $self->wxByGlyph("C") * 27 + $self->wxByGlyph("D") * 35 + $self->wxByGlyph("E") * 100 + $self->wxByGlyph("F") * 20 + $self->wxByGlyph("G") * 14 + $self->wxByGlyph("H") * 42 + $self->wxByGlyph("I") * 63 + $self->wxByGlyph("J") * 3 + $self->wxByGlyph("K") * 6 + $self->wxByGlyph("L") * 35 + $self->wxByGlyph("M") * 20 + $self->wxByGlyph("N") * 56 + $self->wxByGlyph("O") * 56 + $self->wxByGlyph("P") * 17 + $self->wxByGlyph("Q") * 4 + $self->wxByGlyph("R") * 49 + $self->wxByGlyph("S") * 56 + $self->wxByGlyph("T") * 71 + $self->wxByGlyph("U") * 31 + $self->wxByGlyph("V") * 10 + $self->wxByGlyph("W") * 18 + $self->wxByGlyph("X") * 3 + $self->wxByGlyph("Y") * 18 + $self->wxByGlyph("Z") * 2 + $self->wxByGlyph("space") * 332) / 2000
$aw ($self->wxByGlyph("a") * 64 + $self->wxByGlyph("b") * 14 + $self->wxByGlyph("c") * 27 + $self->wxByGlyph("d") * 35 + $self->wxByGlyph("e") * 100 + $self->wxByGlyph("f") * 20 + $self->wxByGlyph("g") * 14 + $self->wxByGlyph("h") * 42 + $self->wxByGlyph("i") * 63 + $self->wxByGlyph("j") * 3 + $self->wxByGlyph("k") * 6 + $self->wxByGlyph("l") * 35 + $self->wxByGlyph("m") * 20 + $self->wxByGlyph("n") * 56 + $self->wxByGlyph("o") * 56 + $self->wxByGlyph("p") * 17 + $self->wxByGlyph("q") * 4 + $self->wxByGlyph("r") * 49 + $self->wxByGlyph("s") * 56 + $self->wxByGlyph("t") * 71 + $self->wxByGlyph("u") * 31 + $self->wxByGlyph("v") * 10 + $self->wxByGlyph("w") * 18 + $self->wxByGlyph("x") * 3 + $self->wxByGlyph("y") * 18 + $self->wxByGlyph("z") * 2 + $self->wxByGlyph("A") * 64 + $self->wxByGlyph("B") * 14 + $self->wxByGlyph("C") * 27 + $self->wxByGlyph("D") * 35 + $self->wxByGlyph("E") * 100 + $self->wxByGlyph("F") * 20 + $self->wxByGlyph("G") * 14 + $self->wxByGlyph("H") * 42 + $self->wxByGlyph("I") * 63 + $self->wxByGlyph("J") * 3 + $self->wxByGlyph("K") * 6 + $self->wxByGlyph("L") * 35 + $self->wxByGlyph("M") * 20 + $self->wxByGlyph("N") * 56 + $self->wxByGlyph("O") * 56 + $self->wxByGlyph("P") * 17 + $self->wxByGlyph("Q") * 4 + $self->wxByGlyph("R") * 49 + $self->wxByGlyph("S") * 56 + $self->wxByGlyph("T") * 71 + $self->wxByGlyph("U") * 31 + $self->wxByGlyph("V") * 10 + $self->wxByGlyph("W") * 18 + $self->wxByGlyph("X") * 3 + $self->wxByGlyph("Y") * 18 + $self->wxByGlyph("Z") * 2 + $self->wxByGlyph("space") * 332) / 2000
Truth table33%1/3
A ||= B
A= $awB= ($self->wxByGlyph("a") * 64 + $self->wxByGlyph("b") * 14 + $self->wxByGlyph("c") * 27 + $self->wxByGlyph("d") * 35 + $self->wxByGlyph("e") * 100 + $self->wxByGlyph("f") * 20 + $self->wxByGlyph("g") * 14 + $self->wxByGlyph("h") * 42 + $self->wxByGlyph("i") * 63 + $self->wxByGlyph("j") * 3 + $self->wxByGlyph("k") * 6 + $self->wxByGlyph("l") * 35 + $self->wxByGlyph("m") * 20 + $self->wxByGlyph("n") * 56 + $self->wxByGlyph("o") * 56 + $self->wxByGlyph("p") * 17 + $self->wxByGlyph("q") * 4 + $self->wxByGlyph("r") * 49 + $self->wxByGlyph("s") * 56 + $self->wxByGlyph("t") * 71 + $self->wxByGlyph("u") * 31 + $self->wxByGlyph("v") * 10 + $self->wxByGlyph("w") * 18 + $self->wxByGlyph("x") * 3 + $self->wxByGlyph("y") * 18 + $self->wxByGlyph("z") * 2 + $self->wxByGlyph("A") * 64 + $self->wxByGlyph("B") * 14 + $self->wxByGlyph("C") * 27 + $self->wxByGlyph("D") * 35 + $self->wxByGlyph("E") * 100 + $self->wxByGlyph("F") * 20 + $self->wxByGlyph("G") * 14 + $self->wxByGlyph("H") * 42 + $self->wxByGlyph("I") * 63 + $self->wxByGlyph("J") * 3 + $self->wxByGlyph("K") * 6 + $self->wxByGlyph("L") * 35 + $self->wxByGlyph("M") * 20 + $self->wxByGlyph("N") * 56 + $self->wxByGlyph("O") * 56 + $self->wxByGlyph("P") * 17 + $self->wxByGlyph("Q") * 4 + $self->wxByGlyph("R") * 49 + $self->wxByGlyph("S") * 56 + $self->wxByGlyph("T") * 71 + $self->wxByGlyph("U") * 31 + $self->wxByGlyph("V") * 10 + $self->wxByGlyph("W") * 18 + $self->wxByGlyph("X") * 3 + $self->wxByGlyph("Y") * 18 + $self->wxByGlyph("Z") * 2 + $self->wxByGlyph("space") * 332) / 2000
ABresult
1X1
011
000
259 $self->wxByGlyph('a') * 64 +
260 $self->wxByGlyph('b') * 14 +
261 $self->wxByGlyph('c') * 27 +
262 $self->wxByGlyph('d') * 35 +
263 $self->wxByGlyph('e') * 100 +
264 $self->wxByGlyph('f') * 20 +
265 $self->wxByGlyph('g') * 14 +
266 $self->wxByGlyph('h') * 42 +
267 $self->wxByGlyph('i') * 63 +
268 $self->wxByGlyph('j') * 3 +
269 $self->wxByGlyph('k') * 6 +
270 $self->wxByGlyph('l') * 35 +
271 $self->wxByGlyph('m') * 20 +
272 $self->wxByGlyph('n') * 56 +
273 $self->wxByGlyph('o') * 56 +
274 $self->wxByGlyph('p') * 17 +
275 $self->wxByGlyph('q') * 4 +
276 $self->wxByGlyph('r') * 49 +
277 $self->wxByGlyph('s') * 56 +
278 $self->wxByGlyph('t') * 71 +
279 $self->wxByGlyph('u') * 31 +
280 $self->wxByGlyph('v') * 10 +
281 $self->wxByGlyph('w') * 18 +
282 $self->wxByGlyph('x') * 3 +
283 $self->wxByGlyph('y') * 18 +
284 $self->wxByGlyph('z') * 2 +
285 $self->wxByGlyph('A') * 64 +
286 $self->wxByGlyph('B') * 14 +
287 $self->wxByGlyph('C') * 27 +
288 $self->wxByGlyph('D') * 35 +
289 $self->wxByGlyph('E') * 100 +
290 $self->wxByGlyph('F') * 20 +
291 $self->wxByGlyph('G') * 14 +
292 $self->wxByGlyph('H') * 42 +
293 $self->wxByGlyph('I') * 63 +
294 $self->wxByGlyph('J') * 3 +
295 $self->wxByGlyph('K') * 6 +
296 $self->wxByGlyph('L') * 35 +
297 $self->wxByGlyph('M') * 20 +
298 $self->wxByGlyph('N') * 56 +
299 $self->wxByGlyph('O') * 56 +
300 $self->wxByGlyph('P') * 17 +
301 $self->wxByGlyph('Q') * 4 +
302 $self->wxByGlyph('R') * 49 +
303 $self->wxByGlyph('S') * 56 +
304 $self->wxByGlyph('T') * 71 +
305 $self->wxByGlyph('U') * 31 +
306 $self->wxByGlyph('V') * 10 +
307 $self->wxByGlyph('W') * 18 +
308 $self->wxByGlyph('X') * 3 +
309 $self->wxByGlyph('Y') * 18 +
310 $self->wxByGlyph('Z') * 2 +
311 $self->wxByGlyph('space') * 332
312 ) / 2000);
313 16 return int($aw);
314 }
315  
316 =item $flags = $font->flags()
317  
318 Return the font's flags value.
319  
320 =cut
321  
322 16 ▶sub flags { return $_[0]->data->{'flags'}; }
Subroutine flags: called CC=1 SCAR=0.0
Pod documented
323  
324 =item $stemv = $font->stemv()
325  
326 Return the font's stemv value.
327  
328 =cut
329  
330 16 ▶sub stemv { return $_[0]->data->{'stemv'}; }
Subroutine stemv: called CC=1 SCAR=0.0
Pod documented
331  
332 =item $stemh = $font->stemh()
333  
334 Return the font's stemh value.
335  
336 =cut
337  
338 16 ▶sub stemh { return $_[0]->data->{'stemh'}; }
Subroutine stemh: called CC=1 SCAR=0.0
Pod documented
339  
340 =item $italicangle = $font->italicangle()
341  
342 Return the font's italicangle value.
343  
344 =cut
345  
346 16 ▶sub italicangle { return $_[0]->data->{'italicangle'}; }
Subroutine italicangle: called CC=1 SCAR=0.0
Pod documented
347  
348 =item $isfixedpitch = $font->isfixedpitch()
349  
350 Return the font's isfixedpitch flag.
351  
352 =cut
353  
354 0 ▶sub isfixedpitch { return $_[0]->data->{'isfixedpitch'}; }
Subroutine isfixedpitch: not called CC=1 SCAR=6.9
Pod documented
355  
356 =item $underlineposition = $font->underlineposition()
357  
358 Return the font's underlineposition value.
359  
360 =cut
361  
362 0 ▶sub underlineposition { return $_[0]->data->{'underlineposition'}; }
Subroutine underlineposition: not called CC=1 SCAR=6.9
Pod documented
363  
364 =item $underlinethickness = $font->underlinethickness()
365  
366 Return the font's underlinethickness value.
367  
368 =cut
369  
370 0 ▶sub underlinethickness { return $_[0]->data->{'underlinethickness'}; }
Subroutine underlinethickness: not called CC=1 SCAR=6.9
Pod documented
371  
372 =item $ascender = $font->ascender()
373  
374 Return the font's ascender value.
375  
376 =cut
377  
378 16 ▶sub ascender { return $_[0]->data->{'ascender'}; }
Subroutine ascender: called CC=1 SCAR=0.0
Pod documented
379  
380 =item $descender = $font->descender()
381  
382 Return the font's descender value.
383  
384 =cut
385  
386 16 ▶sub descender { return $_[0]->data->{'descender'}; }
Subroutine descender: called CC=1 SCAR=0.0
Pod documented
387  
388 =back
389  
390 =head1 GLYPH RELATED METHODS
391  
392 =over 4
393  
394 =item @names = $font->glyphNames()
395  
396 Return the defined glyph names of the font.
397  
398 =cut
399  
400 0 ▶sub glyphNames { return keys %{$_[0]->data->{'wx'}}; }
Subroutine glyphNames: not called CC=1 SCAR=6.9
Pod documented
401  
402 =item $glNum = $font->glyphNum()
403  
404 Return the number of defined glyph names of the font.
405  
406 =cut
407  
408 0 ▶sub glyphNum { return scalar keys %{$_[0]->data->{'wx'}}; }
Subroutine glyphNum: not called CC=1 SCAR=6.9
Pod documented
409  
410 =item $uni = $font->uniByGlyph($char)
411  
412 Return the unicode by glyph name.
413  
414 =cut
415  
416 0 ▶sub uniByGlyph { return $_[0]->data->{'n2u'}->{$_[1]}; }
Subroutine uniByGlyph: not called CC=1 SCAR=6.9
Pod documented
417  
418 =item $uni = $font->uniByEnc($char)
419  
420 Return the unicode by the fonts encoding map.
421  
422 =cut
423  
424 256 ▶sub uniByEnc { return $_[0]->data->{'e2u'}->[$_[1]]; }
Subroutine uniByEnc: called CC=1 SCAR=0.0
Pod documented
425  
426 =item $uni = $font->uniByMap($char)
427  
428 Return the unicode by the font's default map.
429  
430 =cut
431  
432 0 ▶sub uniByMap { return $_[0]->data->{'uni'}->[$_[1]]; }
Subroutine uniByMap: not called CC=1 SCAR=6.9
Pod documented
433  
434 =item $char = $font->encByGlyph($glyph)
435  
436 Return the character by the given glyph name of the font's encoding map.
437  
438 =cut
439  
440 0 ▶sub encByGlyph { return $_[0]->data->{'n2e'}->{$_[1]} || 0; }
Subroutine encByGlyph: not called CC=2 SCAR=17.9
Pod documented
Condition0%0/2
$_[0]->data->{'n2e'}{$_[1]} || 0
l!l
00
MC/DC0%0/1
$_[0]->data->{'n2e'}{$_[1]} || 0
$_[0]->data->{'n2e'}{$_[1]}
Truth table0%0/2
A
A= $_[0]->data->{'n2e'}{$_[1]}
Aresult
11
00
441  
442 =item $char = $font->encByUni($uni)
443  
444 Return the character by the given unicode of the font's encoding map.
445  
446 =cut
447  
448 27 ▶sub encByUni { return $_[0]->data->{'u2e'}->{$_[1]} || $_[0]->data->{'u2c'}->{$_[1]} || 0; }
Subroutine encByUni: called CC=3 SCAR=14.2
Pod documented
Condition40%2/5
$_[0]->data->{'u2e'}{$_[1]} || $_[0]->data->{'u2c'}{$_[1]} || 0
l!l
270
$_[0]->data->{"u2e"}{$_[1]} or $_[0]->data->{"u2c"}{$_[1]}
l!l&&r!l&&!r
2700
MC/DC0%0/2
$_[0]->data->{'u2e'}{$_[1]} || $_[0]->data->{'u2c'}{$_[1]} || 0
$_[0]->data->{"u2e"}{$_[1]} $_[0]->data->{"u2c"}{$_[1]}
Truth table33%1/3
A or B
A= $_[0]->data->{"u2e"}{$_[1]}B= $_[0]->data->{"u2c"}{$_[1]}
ABresult
1X1
011
000
449  
450 =item $char = $font->mapByGlyph($glyph)
451  
452 Return the character by the given glyph name of the font's default map.
453  
454 =cut
455  
456 0 ▶sub mapByGlyph { return $_[0]->data->{'n2c'}->{$_[1]} || 0; }
Subroutine mapByGlyph: not called CC=2 SCAR=17.9
Pod documented
Condition0%0/2
$_[0]->data->{'n2c'}{$_[1]} || 0
l!l
00
MC/DC0%0/1
$_[0]->data->{'n2c'}{$_[1]} || 0
$_[0]->data->{'n2c'}{$_[1]}
Truth table0%0/2
A
A= $_[0]->data->{'n2c'}{$_[1]}
Aresult
11
00
457  
458 =item $char = $font->mapByUni($uni)
459  
460 Return the character by the given unicode of the fonts default map.
461  
462 =cut
463  
464 0 ▶sub mapByUni { return $_[0]->data->{'u2c'}->{$_[1]} || 0; }
Subroutine mapByUni: not called CC=2 SCAR=17.9
Pod documented
Condition0%0/2
$_[0]->data->{'u2c'}{$_[1]} || 0
l!l
00
MC/DC0%0/1
$_[0]->data->{'u2c'}{$_[1]} || 0
$_[0]->data->{'u2c'}{$_[1]}
Truth table0%0/2
A
A= $_[0]->data->{'u2c'}{$_[1]}
Aresult
11
00
465  
466 =item $name = $font->glyphByUni($uni)
467  
468 Return the glyph's name by the font's unicode map.
469 B<BEWARE:> non-standard glyph-names are mapped onto
470 the ms-symbol area (0xF000).
471  
472 =cut
473  
474 0 ▶sub glyphByUni { return $_[0]->data->{'u2n'}->{$_[1]} || '.notdef'; }
Subroutine glyphByUni: not called CC=2 SCAR=17.9
Pod documented
Condition0%0/2
$_[0]->data->{'u2n'}{$_[1]} || '.notdef'
l!l
00
MC/DC0%0/1
$_[0]->data->{'u2n'}{$_[1]} || '.notdef'
$_[0]->data->{'u2n'}{$_[1]}
Truth table0%0/2
A
A= $_[0]->data->{'u2n'}{$_[1]}
Aresult
11
00
475  
476 =item $name = $font->glyphByEnc($char)
477  
478 Return the glyph's name by the font's encoding map.
479  
480 =cut
481  
482 sub glyphByEnc {
483 25885 ▶ my ($self, $e) = @_;
Subroutine glyphByEnc: called CC=1 SCAR=0.0
Pod documented
484 25885 my $g = $self->data->{'e2n'}->[$e];
485 25885 return $g;
486 }
487  
488 =item $name = $font->glyphByMap($char)
489  
490 Return the glyph's name by the font's default map.
491  
492 =cut
493  
494 0 ▶sub glyphByMap { return $_[0]->data->{'char'}->[$_[1]]; }
Subroutine glyphByMap: not called CC=1 SCAR=6.9
Pod documented
495  
496 =item $width = $font->wxByGlyph($glyph)
497  
498 Return the glyph's width.
499  
500 =cut
501  
502 sub wxByGlyph {
503 848 ▶ my $self = shift();
Subroutine wxByGlyph: called CC=7 SCAR=19.9
Pod documented
504 848 my $glyph = shift();
505 848 my $width;
506 848 ▶ if (ref($self->data->{'wx'}) eq 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $self->data->{'wx'} eq 'HASH') { } 795 53 848
507 795 $width = $self->data->{'wx'}->{$glyph};
508 795 ▶ $width //= $self->missingwidth();
Condition66%2/3
$width //= $self->missingwidth
l!l&&r!l&&!r
6910104
MC/DC50%1/2
$width //= $self->missingwidth
$width $self->missingwidth
Truth table66%2/3
A //= B
A= $widthB= $self->missingwidth
ABresult
1X1
011
000
509 795 ▶ $width //= 300;
Condition100%2/2
$width //= 300
l!l
691104
MC/DC100%1/1
$width //= 300
$width
Truth table100%2/2
A
A= $width
Aresult
11
00
510 }
511 else {
512 53 my $cid = $self->cidByUni(uniByName($glyph));
513 53 ▶ $width = $self->data->{'wx'}->[$cid] if defined $cid;
Branch: 1 branch
BranchTrueFalseTotal
if defined $cid 53 0 53
514 53 ▶ $width //= $self->missingwidth();
Condition33%1/3
$width //= $self->missingwidth
l!l&&r!l&&!r
5300
MC/DC0%0/2
$width //= $self->missingwidth
$width $self->missingwidth
Truth table33%1/3
A //= B
A= $widthB= $self->missingwidth
ABresult
1X1
011
000
515 53 ▶ $width //= 300;
Condition50%1/2
$width //= 300
l!l
530
MC/DC0%0/1
$width //= 300
$width
Truth table50%1/2
A
A= $width
Aresult
11
00
516 }
517 848 return $width;
518 }
519  
520 =item $width = $font->wxByUni($uni)
521  
522 Return the unicode's width.
523  
524 =cut
525  
526 sub wxByUni {
527 0 ▶ my $self = shift();
Subroutine wxByUni: not called CC=4 SCAR=30.0
Pod documented
528 0 my $val = shift();
529 0 my $gid = $self->glyphByUni($val);
530 0 my $width;
531 0 ▶ $width = $self->data->{'wx'}->{$gid} if defined $gid;
Branch: 1 branch
BranchTrueFalseTotal
if defined $gid 0 0 0
532 0 ▶ $width //= $self->missingwidth();
Condition0%0/3
$width //= $self->missingwidth
l!l&&r!l&&!r
000
MC/DC0%0/2
$width //= $self->missingwidth
$width $self->missingwidth
Truth table0%0/3
A //= B
A= $widthB= $self->missingwidth
ABresult
1X1
011
000
533 0 ▶ $width //= 300;
Condition0%0/2
$width //= 300
l!l
00
MC/DC0%0/1
$width //= 300
$width
Truth table0%0/2
A
A= $width
Aresult
11
00
534 0 return $width;
535 }
536  
537 =item $width = $font->wxByEnc($char)
538  
539 Return the character's width based on the current encoding.
540  
541 =cut
542  
543 sub wxByEnc {
544 12317 ▶ my ($self, $e) = @_;
Subroutine wxByEnc: called CC=4 SCAR=13.9
Pod documented
545 12317 my $glyph = $self->glyphByEnc($e);
546 12317 my $width;
547 12317 ▶ $width = $self->data->{'wx'}->{$glyph} if defined $glyph;
Branch: 1 branch
BranchTrueFalseTotal
if defined $glyph 12317 0 12317
548 12317 ▶ $width //= $self->missingwidth();
Condition100%3/3
$width //= $self->missingwidth
l!l&&r!l&&!r
1198629239
MC/DC100%2/2
$width //= $self->missingwidth
$width $self->missingwidth
Truth table100%3/3
A //= B
A= $widthB= $self->missingwidth
ABresult
1X1
011
000
549 12317 ▶ $width //= 300;
Condition100%2/2
$width //= 300
l!l
1227839
MC/DC100%1/1
$width //= 300
$width
Truth table100%2/2
A
A= $width
Aresult
11
00
550 12317 return $width;
551 }
552  
553 =item $width = $font->wxByMap($char)
554  
555 Return the character's width based on the font's default encoding.
556  
557 =cut
558  
559 sub wxByMap {
560 0 ▶ my ($self, $map) = @_;
Subroutine wxByMap: not called CC=4 SCAR=30.0
Pod documented
561 0 my $glyph = $self->glyphByMap($map);
562 0 my $width;
563 0 ▶ $width = $self->data->{'wx'}->{$glyph} if defined $glyph;
Branch: 1 branch
BranchTrueFalseTotal
if defined $glyph 0 0 0
564 0 ▶ $width //= $self->missingwidth();
Condition0%0/3
$width //= $self->missingwidth
l!l&&r!l&&!r
000
MC/DC0%0/2
$width //= $self->missingwidth
$width $self->missingwidth
Truth table0%0/3
A //= B
A= $widthB= $self->missingwidth
ABresult
1X1
011
000
565 0 ▶ $width //= 300;
Condition0%0/2
$width //= 300
l!l
00
MC/DC0%0/1
$width //= 300
$width
Truth table0%0/2
A
A= $width
Aresult
11
00
566 0 return $width;
567 }
568  
569 =item $wd = $font->width($text)
570  
571 Return the width of $text as if it were at size 1.
572  
573 =cut
574  
575 sub width {
576 185 ▶ my ($self, $text) = @_;
Subroutine width: called CC=7 SCAR=21.3
Pod documented
577 185 ▶ $text = $self->strByUtf($text) if utf8::is_utf8($text);
Branch: 1 branch
BranchTrueFalseTotal
if utf8::is_utf8($text) 6 179 185
578  
579 185 my @cache;
580 185 my $width = 0;
581 185 ▶ my $kern = $self->{'-dokern'} && ref($self->data->{'kern'});
Condition33%1/3
$self->{'-dokern'} && ref $self->data->{'kern'}
!ll&&!rl&&r
18500
MC/DC0%0/2
$self->{'-dokern'} && ref $self->data->{'kern'}
$self->{'-dokern'} ref $self->data->{'kern'}
Truth table33%1/3
A && B
A= $self->{'-dokern'}B= ref $self->data->{'kern'}
ABresult
0X0
100
111
582 185 my $last_glyph = '';
583 185 foreach my $n (unpack('C*', $text)) {
584 2710 ▶ $cache[$n] //= $self->wxByEnc($n);
Condition66%2/3
$cache[$n] //= $self->wxByEnc($n)
l!l&&r!l&&!r
22974130
MC/DC0%0/2
$cache[$n] //= $self->wxByEnc($n)
$cache[$n] $self->wxByEnc($n)
Truth table66%2/3
A //= B
A= $cache[$n]B= $self->wxByEnc($n)
ABresult
1X1
011
000
585 2710 $width += $cache[$n];
586 2710 ▶ if ($kern) {
Branch: 1 branch
BranchTrueFalseTotal
if ($kern) 0 2710 2710
587 0 ▶ $width += ($self->data->{'kern'}->{$last_glyph . ':' . $self->data->{'e2n'}->[$n]} // 0);
Condition0%0/2
$self->data->{"kern"}{$last_glyph . ':' . $self->data->{"e2n"}[$n]} // 0
l!l
00
MC/DC0%0/1
$self->data->{"kern"}{$last_glyph . ':' . $self->data->{"e2n"}[$n]} // 0
$self->data->{"kern"}{$last_glyph . ':' . $self->data->{"e2n"}[$n]}
Truth table0%0/2
A
A= $self->data->{"kern"}{$last_glyph . ':' . $self->data->{"e2n"}[$n]}
Aresult
11
00
588 0 $last_glyph = $self->data->{'e2n'}->[$n];
589 }
590 }
591 185 $width /= 1000;
592 185 return $width;
593 }
594  
595 =item @widths = $font->width_array($text)
596  
597 Return the widths of the words in $text as if they were at size 1.
598  
599 =cut
600  
601 sub width_array {
602 0 ▶ my ($self, $text) = @_;
Subroutine width_array: not called CC=2 SCAR=17.9
Pod documented
603 0 ▶ $text = $self->utfByStr($text) unless utf8::is_utf8($text);
Branch: 1 branch
BranchTrueFalseTotal
unless utf8::is_utf8($text) 0 0 0
604 0 my @widths = map { $self->width($_) } split(/\s+/, $text);
605 0 return @widths;
606 }
607  
608 =back
609  
610 =head1 STRING METHODS
611  
612 =over
613  
614 =item $utf8_string = $font->utfByStr($string)
615  
616 Return the utf8-string from string based on the font's encoding map.
617  
618 =cut
619  
620 sub utfByStr {
621 0 ▶ my ($self, $string) = @_;
Subroutine utfByStr: not called CC=1 SCAR=6.9
Pod documented
622 0 $string = pack('U*', map { $self->uniByEnc($_) } unpack('C*', $string));
623 0 utf8::upgrade($string);
624 0 return $string;
625 }
626  
627 =item $string = $font->strByUtf($utf8_string)
628  
629 Return the encoded string from utf8-string based on the font's encoding map.
630  
631 =cut
632  
633 sub strByUtf {
634 9 ▶ my ($self, $string) = @_;
Subroutine strByUtf: called CC=1 SCAR=0.0
Pod documented
635 9 $string = pack('C*', map { $self->encByUni($_) & 0xFF } unpack('U*', $string));
636 9 utf8::downgrade($string);
637 9 return $string;
638 }
639  
640 =item $pdf_string = $font->textByStr($text)
641  
642 Return a properly formatted representation of $text for use in the PDF.
643  
644 =cut
645  
646 sub textByStr {
647 30 ▶ my ($self, $string) = @_;
Subroutine textByStr: called CC=2 SCAR=7.0
Pod documented
648 30 ▶ $string = $self->strByUtf($string) if utf8::is_utf8($string);
Branch: 1 branch
BranchTrueFalseTotal
if utf8::is_utf8($string) 3 27 30
649  
650 30 my $text = $string;
651 30 $text =~ s/\\/\\\\/go;
652 30 $text =~ s/([\x00-\x1f])/sprintf('\%03lo', ord($1))/ge;
653 30 $text =~ s/([\{\}\[\]\(\)])/\\$1/g;
654 30 return $text;
655 }
656  
657 sub textByStrKern {
658 0 ▶ my ($self, $string) = @_;
Subroutine textByStrKern: not called CC=9 SCAR=45.0
Pod undocumented
659 0 ▶ return '(' . $self->textByStr($string) . ')' unless $self->{'-dokern'} and ref($self->data->{'kern'});
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"-dokern"} and ref $self->data->{"kern"} 0 0 0
Condition0%0/3
$self->{"-dokern"} and ref $self->data->{"kern"}
!ll&&!rl&&r
000
MC/DC0%0/2
$self->{"-dokern"} and ref $self->data->{"kern"}
$self->{"-dokern"} ref $self->data->{"kern"}
Truth table0%0/3
A and B
A= $self->{"-dokern"}B= ref $self->data->{"kern"}
ABresult
0X0
100
111
660  
661 0 ▶ $string = $self->strByUtf($string) if utf8::is_utf8($string);
Branch: 1 branch
BranchTrueFalseTotal
if utf8::is_utf8($string) 0 0 0
662  
663 0 my $text = ' ';
664 0 my $tBefore = 0;
665 0 my $last_glyph = '';
666 0 foreach my $n (unpack('C*', $string)) {
667 0 ▶ if (defined $self->data->{'kern'}->{$last_glyph . ':' . $self->data->{'e2n'}->[$n]}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->data->{"kern"}{$last_glyph . ':' . $self->data->{"e2n"}[$n]}) 0 0 0
668 0 ▶ $text .= ') ' if $tBefore;
Branch: 1 branch
BranchTrueFalseTotal
if $tBefore 0 0 0
669 0 $text .= sprintf('%i ', -($self->data->{'kern'}->{$last_glyph . ':' . $self->data->{'e2n'}->[$n]}));
670 0 $tBefore = 0;
671 }
672 0 $last_glyph = $self->data->{'e2n'}->[$n];
673 0 my $t = pack('C', $n);
674 0 $t =~ s/\\/\\\\/g;
675 0 $t =~ s/([\x00-\x1f])/sprintf('\%03lo', ord($1))/ge;
676 0 $t =~ s/([\{\}\[\]\(\)])/\\$1/g;
677 0 ▶ $text .= '(' unless $tBefore;
Branch: 1 branch
BranchTrueFalseTotal
unless $tBefore 0 0 0
678 0 $text .= "$t";
679 0 $tBefore = 1;
680 }
681 0 ▶ $text .= ') ' if $tBefore;
Branch: 1 branch
BranchTrueFalseTotal
if $tBefore 0 0 0
682 0 return $text;
683 }
684  
685 # Maintainer's note: $size here is used solely as a flag to determine whether or
686 # not to append a text-showing operator (TJ or Tj).
687 sub text {
688 30 ▶ my ($self, $string, $size, $indent) = @_;
Subroutine text: called CC=6 SCAR=23.5
Pod undocumented
689 30 my $text = $self->textByStr($string);
690  
691 30 ▶ if (defined $size and $self->{'-dokern'}) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $size and $self->{'-dokern'}) { } 0 30 30
elsif (defined $size) { } 30 0 30
Condition33%1/3
defined $size and $self->{"-dokern"}
!ll&&!rl&&r
0300
MC/DC0%0/2
defined $size and $self->{"-dokern"}
defined $size $self->{"-dokern"}
Truth table33%1/3
A and B
A= defined $sizeB= $self->{"-dokern"}
ABresult
0X0
100
111
692 0 $text = $self->textByStrKern($string);
693 0 ▶ return "[ $indent $text ] TJ" if $indent;
Branch: 1 branch
BranchTrueFalseTotal
if $indent 0 0 0
694 0 return "[ $text ] TJ";
695 }
696 elsif (defined $size) {
697 30 ▶ return "[ $indent ($text) ] TJ" if $indent;
Branch: 1 branch
BranchTrueFalseTotal
if $indent 12 18 30
698 18 return "($text) Tj";
699 }
700 else {
701 0 return "($text)";
702 }
703 }
704  
705 34 ▶sub isvirtual { return }
Subroutine isvirtual: called CC=1 SCAR=0.0
Pod undocumented
706  
707 =back
708  
709 =cut
710  
711 10 1;
« API2/Resource/XObject/Image/PNM.pm ↑ Summary API2/Basic/PDF/Pages.pm »