API3/Compat/API2/Resource/BaseFont.pm

filter: Statementstmt 10.3% 27 / 262 Branchbran 0.0% 0 / 78 Conditioncond 0.0% 0 / 68 MC/DCmcdc 0.0% 0 / 36 Subroutinesub 15.2% 9 / 59 Podpod 90.0% 45 / 50 totaltotal 14.6% 81 / 553 CC 70 SCAR 45.9
CC
70
Cov
7%
descrByData
462.0
tounicodemap
90.0
textByStrKern
90.0
CRAP 98.7
« API3/Compat/API2/Content.pm ↑ Summary API3/Compat/API2/Basic/TTF/XMLparse.pm »
1 #=======================================================================
2 # ____ ____ _____ _ ____ ___ ____
3 # | _ \| _ \| ___| _ _ / \ | _ \_ _| |___ \
4 # | |_) | | | | |_ (_) (_) / _ \ | |_) | | __) |
5 # | __/| |_| | _| _ _ / ___ \| __/| | / __/
6 # |_| |____/|_| (_) (_) /_/ \_\_| |___| |_____|
7 #
8 # A Perl Module Chain to faciliate the Creation and Modification
9 # of High-Quality "Portable Document Format (PDF)" Files.
10 #
11 # Copyright 1999-2005 Alfred Reibenschuh <areibens@cpan.org>.
12 #
13 #=======================================================================
14 #
15 # This library is free software; you can redistribute it and/or
16 # modify it under the terms of the GNU Lesser General Public
17 # License as published by the Free Software Foundation; either
18 # version 2 of the License, or (at your option) any later version.
19 #
20 # This library is distributed in the hope that it will be useful,
21 # but WITHOUT ANY WARRANTY; without even the implied warranty of
22 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
23 # Lesser General Public License for more details.
24 #
25 # You should have received a copy of the GNU Lesser General Public
26 # License along with this library; if not, write to the
27 # Free Software Foundation, Inc., 59 Temple Place - Suite 330,
28 # Boston, MA 02111-1307, USA.
29 #
30 # $Id: BaseFont.pm,v 2.9 2007/10/16 20:08:19 areibens Exp $
31 #
32 #=======================================================================
33 package PDF::API3::Compat::API2::Resource::BaseFont;
34
35 1 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
36
37 1 ▶ use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
38 1 ▶ use Encode qw(:all);
Subroutine BEGIN: called CC=1 SCAR=0.0
39
40 1 ▶ use PDF::API3::Compat::API2::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
41 1 ▶ use PDF::API3::Compat::API2::Basic::PDF::Utils;
Subroutine BEGIN: called CC=1 SCAR=0.0
42 1 ▶ use PDF::API3::Compat::API2::Resource;
Subroutine BEGIN: called CC=1 SCAR=0.0
43 1 ▶ use Compress::Zlib;
Subroutine BEGIN: called CC=1 SCAR=0.0
44
45 1 ▶ use vars qw(@ISA $VERSION);
Subroutine BEGIN: called CC=1 SCAR=0.0
46
47 1 @ISA = qw( PDF::API3::Compat::API2::Resource );
48
49 1 ( $VERSION ) = sprintf '%i.%03i', split(/\./,('$Revision: 2.9 $' =~ /Revision: (\S+)\s/)[0]); # $Date: 2007/10/16 20:08:19 $
50
51 }
52 1 ▶no warnings qw[ deprecated recursion uninitialized ];
Subroutine BEGIN: called CC=1 SCAR=0.0
53
54 =item $font = PDF::API3::Compat::API2::Resource::BaseFont->new $pdf, $name
55
56 Returns a font resource object.
57
58 =cut
59
60 0 ▶sub new {
Subroutine new: not called CC=3 SCAR=24.8
Pod documented
61 0 my ($class,$pdf,$name) = @_;
62 0 my $self;
63
64 0 ▶ $class = ref $class if ref $class;
Branch: 1 branch
BranchTrueFalseTotal
if ref $class 0 0 0
65 0 $self=$class->SUPER::new($pdf,$name);
66
67 0 ▶ $pdf->new_obj($self) unless($self->is_obj($pdf));
Branch: 1 branch
BranchTrueFalseTotal
unless $self->is_obj($pdf) 0 0 0
68
69 0 $self->{Type} = PDFName('Font');
70
71 0 $self->{' apipdf'}=$pdf;
72 0 return($self);
73 }
74
75 =item $font = PDF::API3::Compat::API2::Resource::BaseFont->new_api $api, $name
76
77 Returns a font resource object. This method is different from 'new' that
78 it needs an PDF::API3::Compat::API2-object rather than a Text::PDF::File-object.
79
80 =cut
81
82 0 ▶sub new_api {
Subroutine new_api: not called CC=1 SCAR=6.9
Pod documented
83 0 my ($class,$api,@opts)=@_;
84
85 0 my $obj=$class->new($api->{pdf},@opts);
86 0 $obj->{' api'}=$api;
87
88 0 return($obj);
89 }
90
91 0 ▶sub data { return( $_[0]->{' data'} ); }
Subroutine data: not called CC=1 SCAR=6.9
Pod undocumented
92
93 =item $descriptor = $font->descrByData()
94
95 Returns the fonts FontDescriptor key-structure based on the fonts data.
96
97 =cut
98
99 0 ▶sub descrByData {
Subroutine descrByData: not called CC=21 SCAR=61.4
Pod documented
100 0 my $self=shift @_;
101
102 0 my $des=PDFDict();
103 0 $self->{' apipdf'}->new_obj($des);
104
105 ### $self->{'FontDescriptor'}=$des;
106
107 0 $des->{'Type'}=PDFName('FontDescriptor');
108 0 $des->{'FontName'}=PDFName($self->fontname);
109
110 0 ▶ my @w = map { PDFNum($_ || 0) } $self->fontbbox;
Condition0%0/2
$_ || 0
l!l
00
MC/DC0%0/1
$_ || 0
$_
Truth table0%0/2
A
A= $_
Aresult
11
00
111 0 $des->{'FontBBox'}=PDFArray(@w);
112
113 # unless($self->issymbol) {
114 0 ▶ $des->{'Ascent'}=PDFNum($self->ascender || 0);
Condition0%0/2
$self->ascender || 0
l!l
00
MC/DC0%0/1
$self->ascender || 0
$self->ascender
Truth table0%0/2
A
A= $self->ascender
Aresult
11
00
115 0 ▶ $des->{'Descent'}=PDFNum($self->descender || 0);
Condition0%0/2
$self->descender || 0
l!l
00
MC/DC0%0/1
$self->descender || 0
$self->descender
Truth table0%0/2
A
A= $self->descender
Aresult
11
00
116 0 ▶ $des->{'ItalicAngle'}=PDFNum($self->italicangle || 0.0);
Condition0%0/2
$self->italicangle || 0.0
l!l
00
MC/DC0%0/1
$self->italicangle || 0.0
$self->italicangle
Truth table0%0/2
A
A= $self->italicangle
Aresult
11
00
117 0 ▶ $des->{'XHeight'}=PDFNum($self->xheight || (($self->fontbbox)[3]*0.5) || 500);
Condition0%0/5
$self->xheight || ($self->fontbbox)[3] * 0.5 || 500
l!l
00
$self->xheight or ($self->fontbbox)[3] * "0.5"
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->xheight || ($self->fontbbox)[3] * 0.5 || 500
$self->xheight ($self->fontbbox)[3] * "0.5"
Truth table0%0/3
A or B
A= $self->xheightB= ($self->fontbbox)[3] * "0.5"
ABresult
1X1
011
000
118 0 ▶ $des->{'CapHeight'}=PDFNum($self->capheight || ($self->fontbbox)[3] || 800);
Condition0%0/5
$self->capheight || ($self->fontbbox)[3] || 800
l!l
00
$self->capheight or ($self->fontbbox)[3]
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->capheight || ($self->fontbbox)[3] || 800
$self->capheight ($self->fontbbox)[3]
Truth table0%0/3
A or B
A= $self->capheightB= ($self->fontbbox)[3]
ABresult
1X1
011
000
119 0 ▶ $des->{'StemV'}=PDFNum($self->stemv || 0);
Condition0%0/2
$self->stemv || 0
l!l
00
MC/DC0%0/1
$self->stemv || 0
$self->stemv
Truth table0%0/2
A
A= $self->stemv
Aresult
11
00
120 0 ▶ $des->{'StemH'}=PDFNum($self->stemh || 0);
Condition0%0/2
$self->stemh || 0
l!l
00
MC/DC0%0/1
$self->stemh || 0
$self->stemh
Truth table0%0/2
A
A= $self->stemh
Aresult
11
00
121 0 ▶ $des->{'AvgWidth'}=PDFNum($self->avgwidth || 300);
Condition0%0/2
$self->avgwidth || 300
l!l
00
MC/DC0%0/1
$self->avgwidth || 300
$self->avgwidth
Truth table0%0/2
A
A= $self->avgwidth
Aresult
11
00
122 0 ▶ $des->{'MissingWidth'}=PDFNum($self->missingwidth || 300);
Condition0%0/2
$self->missingwidth || 300
l!l
00
MC/DC0%0/1
$self->missingwidth || 300
$self->missingwidth
Truth table0%0/2
A
A= $self->missingwidth
Aresult
11
00
123 0 ▶ $des->{'MaxWidth'}=PDFNum($self->maxwidth || $self->missingwidth || ($self->fontbbox)[2]);
Condition0%0/6
$self->maxwidth || $self->missingwidth || ($self->fontbbox)[2]
l!l&&r!l&&!r
000
$self->maxwidth or $self->missingwidth
l!l&&r!l&&!r
000
MC/DC0%0/3
$self->maxwidth || $self->missingwidth || ($self->fontbbox)[2]
$self->maxwidth $self->missingwidth ($self->fontbbox)[2]
Truth table0%0/4
A or B || C
A= $self->maxwidthB= $self->missingwidthC= ($self->fontbbox)[2]
ABCresult
1XX1
01X1
0011
0000
124 0 ▶ $des->{'Flags'}=PDFNum($self->flags || 0) unless($self->data->{iscore});
Branch: 1 branch
BranchTrueFalseTotal
unless $self->data->{"iscore"} 0 0 0
Condition0%0/2
$self->flags || 0
l!l
00
MC/DC0%0/1
$self->flags || 0
$self->flags
Truth table0%0/2
A
A= $self->flags
Aresult
11
00
125 0 ▶ if(defined $self->data->{panose}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->data->{"panose"}) 0 0 0
126 0 $des->{Style}=PDFDict();
127 0 $des->{Style}->{Panose}=PDFStrHex($self->data->{panose});
128 }
129 $des->{FontFamily}=PDFStr($self->data->{fontfamily})
130 0 ▶ if(defined $self->data->{fontfamily});
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->data->{"fontfamily"} 0 0 0
131 $des->{FontWeight}=PDFNum($self->data->{fontweight})
132 0 ▶ if(defined $self->data->{fontweight});
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->data->{"fontweight"} 0 0 0
133 $des->{FontStretch}=PDFName($self->data->{fontstretch})
134 0 ▶ if(defined $self->data->{fontstretch});
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->data->{"fontstretch"} 0 0 0
135 # }
136
137 0 return($des);
138 }
139
140 0 ▶sub tounicodemap {
Subroutine tounicodemap: not called CC=9 SCAR=45.0
Pod undocumented
141 0 my $self=shift @_;
142
143 0 ▶ return($self) if(defined $self->{ToUnicode});
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"ToUnicode"} 0 0 0
144
145 0 my $cmap=qq|\%\% Custom\n\%\% CMap\n\%\%\n/CIDInit /ProcSet findresource begin\n|;
146 0 $cmap.=qq|12 dict begin begincmap\n|;
147 0 $cmap.=qq|/CIDSystemInfo <<\n|;
148 0 $cmap.=sprintf(qq| /Registry (%s)\n|,$self->name);
149 0 $cmap.=qq| /Ordering (XYZ)\n|;
150 0 $cmap.=qq| /Supplement 0\n|;
151 0 $cmap.=qq|>> def\n|;
152 0 $cmap.=sprintf(qq|/CMapName /pdfapi2-%s+0 def\n|,$self->name);
153 0 ▶ if(UNIVERSAL::can($self,'uniByCId') && UNIVERSAL::can($self,'glyphNum')) {
Branch: 1 branch
BranchTrueFalseTotal
if (UNIVERSAL::can($self, 'uniByCId') and UNIVERSAL::can($self, 'glyphNum')) { } 0 0 0
Condition0%0/3
UNIVERSAL::can($self, "uniByCId") and UNIVERSAL::can($self, "glyphNum")
!ll&&!rl&&r
000
MC/DC0%0/2
UNIVERSAL::can($self, "uniByCId") and UNIVERSAL::can($self, "glyphNum")
UNIVERSAL::can($self, "uniByCId") UNIVERSAL::can($self, "glyphNum")
Truth table0%0/3
A and B
A= UNIVERSAL::can($self, "uniByCId")B= UNIVERSAL::can($self, "glyphNum")
ABresult
0X0
100
111
154 # this is a type0 font
155 0 $cmap.=sprintf(qq|1 begincodespacerange <0000> <%04X> endcodespacerange\n|,$self->glyphNum-1);
156 0 ▶ for(my $j=0;$j<$self->glyphNum;$j++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($j < $self->glyphNum) 0 0 0
157 0 ▶ my $i = $self->glyphNum - $j > 100 ? 100 : $self->glyphNum - $j;
Branch: 1 branch
BranchTrueFalseTotal
$self->glyphNum - $j > 100 ? : 0 0 0
158 0 ▶ if($j==0) {
Branch: 2 branches
BranchTrueFalseTotal
if ($j == 0) { } 0 0 0
elsif ($j % 100 == 0) { } 0 0 0
159 0 $cmap.=qq|$i beginbfrange\n|;
160 } elsif($j%100 == 0) {
161 0 $cmap.=qq|endbfrange\n|;
162 0 $cmap.=qq|$i beginbfrange\n|;
163 }
164 0 $cmap.=sprintf(qq|<%04x> <%04x> <%04x>\n|,$j,$j,$self->uniByCId($j));
165 }
166 0 $cmap.="endbfrange\n";
167 } else {
168 # everything else is single byte font
169 0 $cmap.=qq|1 begincodespacerange\n<00> <FF>\nendcodespacerange\n|;
170 0 $cmap.=qq|256 beginbfchar\n|;
171 0 ▶ for(my $j=0; $j<256;$j++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($j < 256) 0 0 0
172 0 $cmap.=sprintf(qq|<%02X> <%04X>\n|,$j,$self->uniByEnc($j));
173 }
174 0 $cmap.=qq|endbfchar\n|;
175 }
176 0 $cmap.=qq|endcmap CMapName currendict /CMap defineresource pop end end\n|;
177
178 0 my $tuni=PDFDict();
179 0 $tuni->{Type}=PDFName('CMap');
180 0 $tuni->{CMapName}=PDFName(sprintf(qq|pdfapi2-%s+0|,$self->name));
181 0 $tuni->{CIDSystemInfo}=PDFDict();
182 0 $tuni->{CIDSystemInfo}->{Registry}=PDFStr($self->name);
183 0 $tuni->{CIDSystemInfo}->{Ordering}=PDFStr('XYZ');
184 0 $tuni->{CIDSystemInfo}->{Supplement}=PDFNum(0);
185
186 0 $self->{' apipdf'}->new_obj($tuni);
187 0 $tuni->{' nofilt'}=1;
188 0 $tuni->{' stream'}=Compress::Zlib::compress($cmap);
189 0 $tuni->{Filter}=PDFArray(PDFName('FlateDecode'));
190 0 $self->{ToUnicode}=$tuni;
191 0 return($self);
192 }
193
194
195 =back
196
197 =head1 FONT-MANAGEMENT RELATED METHODS
198
199 =over 4
200
201 =item $name = $font->fontname()
202
203 Returns the fonts name (aka. display-name).
204
205 =cut
206
207 0 ▶sub fontname { return( $_[0]->data->{fontname} ); }
Subroutine fontname: not called CC=1 SCAR=6.9
Pod documented
208
209 =item $name = $font->altname()
210
211 Returns the fonts alternative-name (aka. windows-name for a postscript font).
212
213 =cut
214
215 0 ▶sub altname { return( $_[0]->data->{altname} ); }
Subroutine altname: not called CC=1 SCAR=6.9
Pod documented
216
217 =item $name = $font->subname()
218
219 Returns the fonts subname (aka. font-variant, schriftschnitt).
220
221 =cut
222
223 0 ▶sub subname { return( $_[0]->data->{subname} ); }
Subroutine subname: not called CC=1 SCAR=6.9
Pod documented
224
225 =item $name = $font->apiname()
226
227 Returns the fonts name to be used internally (should be equal to $font->name).
228
229 =cut
230
231 0 ▶sub apiname { return( $_[0]->data->{apiname} ); }
Subroutine apiname: not called CC=1 SCAR=6.9
Pod documented
232
233 =item $issymbol = $font->issymbol()
234
235 Returns the fonts symbol flag.
236
237 =cut
238
239 0 ▶sub issymbol { return( $_[0]->data->{issymbol} ); }
Subroutine issymbol: not called CC=1 SCAR=6.9
Pod documented
240
241 =item $iscff = $font->iscff()
242
243 Returns the fonts compact-font-format flag.
244
245 =cut
246
247 0 ▶sub iscff { return( $_[0]->data->{iscff} ); }
Subroutine iscff: not called CC=1 SCAR=6.9
Pod documented
248
249 =back
250
251 =head1 TYPOGRAPHY RELATED METHODS
252
253 =over 4
254
255 =item ($llx, $lly, $urx, $ury) = $font->fontbbox()
256
257 Returns the fonts bounding-box.
258
259 =cut
260
261 0 ▶sub fontbbox { return( @{$_[0]->data->{fontbbox}} ); }
Subroutine fontbbox: not called CC=1 SCAR=6.9
Pod documented
262
263 =item $capheight = $font->capheight()
264
265 Returns the fonts capheight value.
266
267 =cut
268
269 0 ▶sub capheight { return( $_[0]->data->{capheight} ); }
Subroutine capheight: not called CC=1 SCAR=6.9
Pod documented
270
271 =item $xheight = $font->xheight()
272
273 Returns the fonts xheight value.
274
275 =cut
276
277 0 ▶sub xheight { return( $_[0]->data->{xheight} ); }
Subroutine xheight: not called CC=1 SCAR=6.9
Pod documented
278
279 =item $missingwidth = $font->missingwidth()
280
281 Returns the fonts missingwidth value.
282
283 =cut
284
285 0 ▶sub missingwidth { return( $_[0]->data->{missingwidth} ); }
Subroutine missingwidth: not called CC=1 SCAR=6.9
Pod documented
286
287 =item $maxwidth = $font->maxwidth()
288
289 Returns the fonts maxwidth value.
290
291 =cut
292
293 0 ▶sub maxwidth { return( $_[0]->data->{maxwidth} ); }
Subroutine maxwidth: not called CC=1 SCAR=6.9
Pod documented
294
295 =item $avgwidth = $font->avgwidth()
296
297 Returns the fonts avgwidth value.
298
299 =cut
300
301 0 ▶sub avgwidth {
Subroutine avgwidth: not called CC=2 SCAR=17.9
Pod documented
302 0 my ($self) = @_;
303 0 my $aw=$self->data->{avgwidth};
304 0 ▶ $aw||=((
Condition0%0/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
000
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 table0%0/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
305 $self->wxByGlyph('a')*64 +
306 $self->wxByGlyph('b')*14 +
307 $self->wxByGlyph('c')*27 +
308 $self->wxByGlyph('d')*35 +
309 $self->wxByGlyph('e')*100 +
310 $self->wxByGlyph('f')*20 +
311 $self->wxByGlyph('g')*14 +
312 $self->wxByGlyph('h')*42 +
313 $self->wxByGlyph('i')*63 +
314 $self->wxByGlyph('j')* 3 +
315 $self->wxByGlyph('k')* 6 +
316 $self->wxByGlyph('l')*35 +
317 $self->wxByGlyph('m')*20 +
318 $self->wxByGlyph('n')*56 +
319 $self->wxByGlyph('o')*56 +
320 $self->wxByGlyph('p')*17 +
321 $self->wxByGlyph('q')* 4 +
322 $self->wxByGlyph('r')*49 +
323 $self->wxByGlyph('s')*56 +
324 $self->wxByGlyph('t')*71 +
325 $self->wxByGlyph('u')*31 +
326 $self->wxByGlyph('v')*10 +
327 $self->wxByGlyph('w')*18 +
328 $self->wxByGlyph('x')* 3 +
329 $self->wxByGlyph('y')*18 +
330 $self->wxByGlyph('z')* 2 +
331 $self->wxByGlyph('A')*64 +
332 $self->wxByGlyph('B')*14 +
333 $self->wxByGlyph('C')*27 +
334 $self->wxByGlyph('D')*35 +
335 $self->wxByGlyph('E')*100 +
336 $self->wxByGlyph('F')*20 +
337 $self->wxByGlyph('G')*14 +
338 $self->wxByGlyph('H')*42 +
339 $self->wxByGlyph('I')*63 +
340 $self->wxByGlyph('J')* 3 +
341 $self->wxByGlyph('K')* 6 +
342 $self->wxByGlyph('L')*35 +
343 $self->wxByGlyph('M')*20 +
344 $self->wxByGlyph('N')*56 +
345 $self->wxByGlyph('O')*56 +
346 $self->wxByGlyph('P')*17 +
347 $self->wxByGlyph('Q')* 4 +
348 $self->wxByGlyph('R')*49 +
349 $self->wxByGlyph('S')*56 +
350 $self->wxByGlyph('T')*71 +
351 $self->wxByGlyph('U')*31 +
352 $self->wxByGlyph('V')*10 +
353 $self->wxByGlyph('W')*18 +
354 $self->wxByGlyph('X')* 3 +
355 $self->wxByGlyph('Y')*18 +
356 $self->wxByGlyph('Z')* 2 +
357 $self->wxByGlyph('space')*332
358 ) / 2000);
359 0 return( int($aw) );
360 }
361
362 =item $flags = $font->flags()
363
364 Returns the fonts flags value.
365
366 =cut
367
368 0 ▶sub flags { return( $_[0]->data->{flags} ); }
Subroutine flags: not called CC=1 SCAR=6.9
Pod documented
369
370 =item $stemv = $font->stemv()
371
372 Returns the fonts stemv value.
373
374 =cut
375
376 0 ▶sub stemv { return( $_[0]->data->{stemv} ); }
Subroutine stemv: not called CC=1 SCAR=6.9
Pod documented
377
378 =item $stemh = $font->stemh()
379
380 Returns the fonts stemh value.
381
382 =cut
383
384 0 ▶sub stemh { return( $_[0]->data->{stemh} ); }
Subroutine stemh: not called CC=1 SCAR=6.9
Pod documented
385
386 =item $italicangle = $font->italicangle()
387
388 Returns the fonts italicangle value.
389
390 =cut
391
392 0 ▶sub italicangle { return( $_[0]->data->{italicangle} ); }
Subroutine italicangle: not called CC=1 SCAR=6.9
Pod documented
393
394 =item $isfixedpitch = $font->isfixedpitch()
395
396 Returns the fonts isfixedpitch flag.
397
398 =cut
399
400 0 ▶sub isfixedpitch { return( $_[0]->data->{isfixedpitch} ); }
Subroutine isfixedpitch: not called CC=1 SCAR=6.9
Pod documented
401
402 =item $underlineposition = $font->underlineposition()
403
404 Returns the fonts underlineposition value.
405
406 =cut
407
408 0 ▶sub underlineposition { return( $_[0]->data->{underlineposition} ); }
Subroutine underlineposition: not called CC=1 SCAR=6.9
Pod documented
409
410 =item $underlinethickness = $font->underlinethickness()
411
412 Returns the fonts underlinethickness value.
413
414 =cut
415
416 0 ▶sub underlinethickness { return( $_[0]->data->{underlinethickness} ); }
Subroutine underlinethickness: not called CC=1 SCAR=6.9
Pod documented
417
418 =item $ascender = $font->ascender()
419
420 Returns the fonts ascender value.
421
422 =cut
423
424 0 ▶sub ascender { return( $_[0]->data->{ascender} ); }
Subroutine ascender: not called CC=1 SCAR=6.9
Pod documented
425
426 =item $descender = $font->descender()
427
428 Returns the fonts descender value.
429
430 =cut
431
432 0 ▶sub descender { return( $_[0]->data->{descender} ); }
Subroutine descender: not called CC=1 SCAR=6.9
Pod documented
433
434 =back
435
436 =head1 GLYPH RELATED METHODS
437
438 =over 4
439
440 =item @names = $font->glyphNames()
441
442 Returns the defined glyph-names of the font.
443
444 =cut
445
446 0 ▶sub glyphNames { return ( keys %{$_[0]->data->{wx}} ); }
Subroutine glyphNames: not called CC=1 SCAR=6.9
Pod documented
447
448 =item $glNum = $font->glyphNum()
449
450 Returns the number of defined glyph-names of the font.
451
452 =cut
453
454 0 ▶sub glyphNum { return ( scalar keys %{$_[0]->data->{wx}} ); }
Subroutine glyphNum: not called CC=1 SCAR=6.9
Pod documented
455
456 =item $uni = $font->uniByGlyph $char
457
458 Returns the unicode by glyph-name.
459
460 =cut
461
462 0 ▶sub uniByGlyph { return( $_[0]->data->{n2u}->{$_[1]} ); }
Subroutine uniByGlyph: not called CC=1 SCAR=6.9
Pod documented
463
464 =item $uni = $font->uniByEnc $char
465
466 Returns the unicode by the fonts encoding map.
467
468 =cut
469
470 0 ▶sub uniByEnc { return($_[0]->data->{e2u}->[$_[1]] ); }
Subroutine uniByEnc: not called CC=1 SCAR=6.9
Pod documented
471
472 =item $uni = $font->uniByMap $char
473
474 Returns the unicode by the fonts default map.
475
476 =cut
477
478 0 ▶sub uniByMap { return($_[0]->data->{uni}->[$_[1]]); }
Subroutine uniByMap: not called CC=1 SCAR=6.9
Pod documented
479
480 =item $char = $font->encByGlyph $glyph
481
482 Returns the character by the given glyph-name of the fonts encoding map.
483
484 =cut
485
486 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
487
488 =item $char = $font->encByUni $uni
489
490 Returns the character by the given unicode of the fonts encoding map.
491
492 =cut
493
494 0 ▶sub encByUni { return( $_[0]->data->{u2e}->{$_[1]} || $_[0]->data->{u2c}->{$_[1]} || 0 ); }
Subroutine encByUni: not called CC=3 SCAR=24.8
Pod documented
Condition0%0/5
$_[0]->data->{'u2e'}{$_[1]} || $_[0]->data->{'u2c'}{$_[1]} || 0
l!l
00
$_[0]->data->{"u2e"}{$_[1]} or $_[0]->data->{"u2c"}{$_[1]}
l!l&&r!l&&!r
000
MC/DC0%0/2
$_[0]->data->{'u2e'}{$_[1]} || $_[0]->data->{'u2c'}{$_[1]} || 0
$_[0]->data->{"u2e"}{$_[1]} $_[0]->data->{"u2c"}{$_[1]}
Truth table0%0/3
A or B
A= $_[0]->data->{"u2e"}{$_[1]}B= $_[0]->data->{"u2c"}{$_[1]}
ABresult
1X1
011
000
495
496 =item $char = $font->mapByGlyph $glyph
497
498 Returns the character by the given glyph-name of the fonts default map.
499
500 =cut
501
502 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
503
504 =item $char = $font->mapByUni $uni
505
506 Returns the character by the given unicode of the fonts default map.
507
508 =cut
509
510 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
511
512 =item $name = $font->glyphByUni $unicode
513
514 Returns the glyphs name by the fonts unicode map.
515 B<BEWARE:> non-standard glyph-names are mapped onto
516 the ms-symbol area (0xF000).
517
518 =cut
519
520 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
521
522 =item $name = $font->glyphByEnc $char
523
524 Returns the glyphs name by the fonts encoding map.
525
526 =cut
527
528 0 ▶sub glyphByEnc {
Subroutine glyphByEnc: not called CC=1 SCAR=6.9
Pod documented
529 0 my ($self,$e)=@_;
530 0 my $g=$self->data->{e2n}->[$e];
531 0 return( $g );
532 }
533
534 =item $name = $font->glyphByMap $char
535
536 Returns the glyphs name by the fonts default map.
537
538 =cut
539
540 0 ▶sub glyphByMap { return ( $_[0]->data->{char}->[$_[1]] ); }
Subroutine glyphByMap: not called CC=1 SCAR=6.9
Pod documented
541
542 =item $width = $font->wxByGlyph $glyph
543
544 Returns the glyphs width.
545
546 =cut
547
548 sub wxByGlyph
549 0 ▶{
Subroutine wxByGlyph: not called CC=6 SCAR=37.4
Pod documented
550 0 my $self=shift;
551 0 my $val=shift;
552 0 my $ret=undef;
553 0 ▶ if(ref($self->data->{wx}) eq 'HASH')
Branch: 1 branch
BranchTrueFalseTotal
if (ref $self->data->{'wx'} eq 'HASH') { } 0 0 0
554 {
555 0 $ret=$self->data->{wx}->{$val};
556 0 ▶ if(!defined($ret))
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $ret) 0 0 0
557 {
558 0 $ret=$self->missingwidth;
559 }
560 0 ▶ if(!defined($ret))
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $ret) 0 0 0
561 {
562 0 $ret=300;
563 }
564 }
565 else
566 {
567 0 my $cid=$self->cidByUni(uniByName($val));
568 0 $ret=$self->data->{wx}->[$cid];
569 0 ▶ if(!defined($ret))
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $ret) 0 0 0
570 {
571 0 $ret=$self->missingwidth;
572 }
573 0 ▶ if(!defined($ret))
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $ret) 0 0 0
574 {
575 0 $ret=300;
576 }
577 }
578 0 return $ret;
579 }
580
581 =item $width = $font->wxByUni $uni
582
583 Returns the unicodes width.
584
585 =cut
586
587 sub wxByUni
588 0 ▶{
Subroutine wxByUni: not called CC=3 SCAR=24.8
Pod documented
589 0 my $self=shift;
590 0 my $val=shift;
591 0 my $gid=$self->glyphByUni($val);
592 0 my $ret=$self->data->{wx}->{$gid};
593 0 ▶ if(!defined($ret))
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $ret) 0 0 0
594 {
595 0 $ret=$self->missingwidth;
596 }
597 0 ▶ if(!defined($ret))
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $ret) 0 0 0
598 {
599 0 $ret=300;
600 }
601 0 return $ret;
602 }
603
604 =item $width = $font->wxByEnc $char
605
606 Returns the characters width based on the current encoding.
607
608 =cut
609
610 sub wxByEnc
611 0 ▶{
Subroutine wxByEnc: not called CC=3 SCAR=24.8
Pod documented
612 0 my ($self,$e)=@_;
613 0 my $g=$self->glyphByEnc($e);
614 0 my $ret=$self->data->{wx}->{$g};
615 0 ▶ if(!defined($ret))
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $ret) 0 0 0
616 {
617 0 $ret=$self->missingwidth;
618 }
619 0 ▶ if(!defined($ret))
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $ret) 0 0 0
620 {
621 0 $ret=300;
622 }
623 0 return $ret;
624 }
625
626 =item $width = $font->wxByMap $char
627
628 Returns the characters width based on the fonts default encoding.
629
630 =cut
631
632 sub wxByMap
633 0 ▶{
Subroutine wxByMap: not called CC=3 SCAR=24.8
Pod documented
634 0 my ($self,$m)=@_;
635 0 my $g=$self->glyphByMap($m);
636 0 my $ret=$self->data->{wx}->{$g};
637 0 ▶ if(!defined($ret))
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $ret) 0 0 0
638 {
639 0 $ret=$self->missingwidth;
640 }
641 0 ▶ if(!defined($ret))
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $ret) 0 0 0
642 {
643 0 $ret=300;
644 }
645 0 return $ret;
646 }
647
648 =item $wd = $font->width $text
649
650 Returns the width of $text as if it were at size 1.
651 B<BEWARE:> works only correctly if a proper perl-string
652 is used either in native or utf8 format (check utf8-flag).
653
654 =cut
655
656 0 ▶sub width {
Subroutine width: not called CC=5 SCAR=34.0
Pod documented
657 0 my ($self,$text)=@_;
658 0 my $width=0;
659 0 ▶ if(is_utf8($text)) {
Branch: 1 branch
BranchTrueFalseTotal
if (&is_utf8($text)) 0 0 0
660 0 $text=$self->strByUtf($text)
661 }
662 0 my $lastglyph='';
663 0 foreach my $n (unpack('C*',$text))
664 {
665 0 $width+=$self->wxByEnc($n);
666 0 ▶ if($self->{-dokern} && ref($self->data->{kern}))
Branch: 1 branch
BranchTrueFalseTotal
if ($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
667 {
668 0 $width+=$self->data->{kern}->{$lastglyph.':'.$self->data->{e2n}->[$n]};
669 0 $lastglyph=$self->data->{e2n}->[$n];
670 }
671 }
672 0 $width/=1000;
673 0 return($width);
674 }
675
676 =item @widths = $font->width_array $text
677
678 Returns the widths of the words in $text as if they were at size 1.
679
680 =cut
681
682 0 ▶sub width_array {
Subroutine width_array: not called CC=2 SCAR=17.9
Pod documented
683 0 my ($self,$text)=@_;
684 0 ▶ if(!is_utf8($text)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (&is_utf8($text)) 0 0 0
685 0 $text=$self->utfByStr($text);
686 }
687 0 my @text=split(/\s+/,$text);
688 0 my @widths=map { $self->width($_) } @text;
689 0 return(@widths);
690 }
691
692 =back
693
694 =head1 STRING METHODS
695
696 =over 4
697
698 =item $utf8string = $font->utfByStr $string
699
700 Returns the utf8-string from string based on the fonts encoding map.
701
702 =cut
703
704 0 ▶sub utfByStr {
Subroutine utfByStr: not called CC=1 SCAR=6.9
Pod documented
705 0 my ($self,$s)=@_;
706 0 $s=pack('U*',map { $self->uniByEnc($_) } unpack('C*',$s));
707 0 utf8::upgrade($s);
708 0 return($s);
709 }
710
711 =item $string = $font->strByUtf $utf8string
712
713 Returns the encoded string from utf8-string based on the fonts encoding map.
714
715 =cut
716
717 0 ▶sub strByUtf {
Subroutine strByUtf: not called CC=1 SCAR=6.9
Pod documented
718 0 my ($self,$s)=@_;
719 0 $s=pack('C*',map { $self->encByUni($_) & 0xFF } unpack('U*',$s));
720 0 utf8::downgrade($s);
721 0 return($s);
722 }
723
724 =item $pdfstring = $font->textByStr $text
725
726 Returns a properly formatted representation of $text for use in the PDF.
727
728 =cut
729
730 sub textByStr
731 0 ▶{
Subroutine textByStr: not called CC=2 SCAR=17.9
Pod documented
732 0 my ($self,$text)=@_;
733 0 my $newtext='';
734 0 ▶ if(is_utf8($text))
Branch: 1 branch
BranchTrueFalseTotal
if (&is_utf8($text)) 0 0 0
735 {
736 0 $text=$self->strByUtf($text);
737 }
738 0 $newtext=$text;
739 0 $newtext=~s/\\/\\\\/go;
740 0 $newtext=~s/([\x00-\x1f])/sprintf('\%03lo',ord($1))/ge;
741 0 $newtext=~s/([\{\}\[\]\(\)])/\\$1/g;
742 0 return($newtext);
743 }
744
745 sub textByStrKern
746 0 ▶{
Subroutine textByStrKern: not called CC=9 SCAR=45.0
Pod undocumented
747 0 my ($self,$text)=@_;
748 0 ▶ if($self->{-dokern} && ref($self->data->{kern}))
Branch: 1 branch
BranchTrueFalseTotal
if ($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
749 {
750 0 my $newtext=' ';
751 0 ▶ if(is_utf8($text))
Branch: 1 branch
BranchTrueFalseTotal
if (&is_utf8($text)) 0 0 0
752 {
753 0 $text=$self->strByUtf($text);
754 }
755
756 0 my $lastglyph='';
757 0 my $tBefore=0;
758 0 foreach my $n (unpack('C*',$text))
759 {
760 0 ▶ if(defined $self->data->{kern}->{$lastglyph.':'.$self->data->{e2n}->[$n]})
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->data->{"kern"}{$lastglyph . ':' . $self->data->{"e2n"}[$n]}) 0 0 0
761 {
762 0 ▶ $newtext.=') ' if($tBefore);
Branch: 1 branch
BranchTrueFalseTotal
if $tBefore 0 0 0
763 0 $newtext.=sprintf('%i ',-($self->data->{kern}->{$lastglyph.':'.$self->data->{e2n}->[$n]}));
764 0 $tBefore=0;
765 }
766 0 $lastglyph=$self->data->{e2n}->[$n];
767 0 my $t=pack('C',$n);
768 0 $t=~s/\\/\\\\/go;
769 0 $t=~s/([\x00-\x1f])/sprintf('\%03lo',ord($1))/ge;
770 0 $t=~s/([\{\}\[\]\(\)])/\\$1/g;
771 0 ▶ $newtext.='(' if(!$tBefore);
Branch: 1 branch
BranchTrueFalseTotal
unless $tBefore 0 0 0
772 0 $newtext.="$t";
773 0 $tBefore=1;
774 }
775 0 ▶ $newtext.=') ' if($tBefore);
Branch: 1 branch
BranchTrueFalseTotal
if $tBefore 0 0 0
776 0 return($newtext);
777 }
778 else
779 {
780 0 return('('.$self->textByStr($text).')');
781 }
782 }
783
784 sub text
785 0 ▶{
Subroutine text: not called CC=8 SCAR=42.8
Pod undocumented
786 0 my ($self,$text,$size,$ident)=@_;
787
788 0 my $newtext=$self->textByStr($text);
789
790 0 ▶ if(defined $size && $self->{-dokern})
Branch: 2 branches
BranchTrueFalseTotal
if (defined $size and $self->{'-dokern'}) { } 0 0 0
elsif (defined $size) { } 0 0 0
Condition0%0/3
defined $size and $self->{"-dokern"}
!ll&&!rl&&r
000
MC/DC0%0/2
defined $size and $self->{"-dokern"}
defined $size $self->{"-dokern"}
Truth table0%0/3
A and B
A= defined $sizeB= $self->{"-dokern"}
ABresult
0X0
100
111
791 {
792 0 $newtext=$self->textByStrKern($text);
793 0 ▶ if(defined($ident) && $ident!=0)
Branch: 1 branch
BranchTrueFalseTotal
if (defined $ident and $ident != 0) { } 0 0 0
Condition0%0/3
defined $ident and $ident != 0
!ll&&!rl&&r
000
MC/DC0%0/2
defined $ident and $ident != 0
defined $ident $ident != 0
Truth table0%0/3
A and B
A= defined $identB= $ident != 0
ABresult
0X0
100
111
794 {
795 0 return("[ $ident $newtext ] TJ");
796 }
797 else
798 {
799 0 return("[ $newtext ] TJ");
800 }
801 }
802 elsif(defined $size)
803 {
804 0 ▶ if(defined($ident) && $ident!=0)
Branch: 1 branch
BranchTrueFalseTotal
if (defined $ident and $ident != 0) { } 0 0 0
Condition0%0/3
defined $ident and $ident != 0
!ll&&!rl&&r
000
MC/DC0%0/2
defined $ident and $ident != 0
defined $ident $ident != 0
Truth table0%0/3
A and B
A= defined $identB= $ident != 0
ABresult
0X0
100
111
805 {
806 0 return("[ $ident ($newtext) ] TJ");
807 }
808 else
809 {
810 0 return("[ ($newtext) ] TJ");
811 }
812 }
813 else
814 {
815 0 return("($newtext)");
816 }
817 }
818
819 0 ▶sub isvirtual { return(0); }
Subroutine isvirtual: not called CC=1 SCAR=6.9
Pod undocumented
820
821 1 1;
822
823 __END__
« API3/Compat/API2/Content.pm ↑ Summary API3/Compat/API2/Basic/TTF/XMLparse.pm »