lib/PDF/Boxer/Role/Text.pm

filter: Statementstmt 37.8% 14 / 37 Branchbran 0.0% 0 / 2 Conditioncond 0.0% 0 / 7 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 14.2% 1 / 7 Podpod 0.0% 0 / 4 totaltotal 24.5% 15 / 61 CC 6 SCAR 22.2
CC
6
Cov
30%
dump_attr
20.0
get_font
6.0
baseline_top
6.0
CRAP 9.2
« lib/PDF/Boxer/Role/SizePosition.pm ↑ Summary lib/PDF/Boxer/Doc.pm »
1 package PDF::Boxer::Role::Text;
2 {
3 3 $PDF::Boxer::Role::Text::VERSION = '0.004';
4 }
5 3 ▶use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 # ABSTRACT: methods & attributes for text boxes
7  
8 3 has 'size' => ( isa => 'Int', is => 'ro', default => 14 );
9 3 has 'font' => ( isa => 'Str', is => 'ro', default => 'Helvetica' );
10 3 has 'font_bold' => ( isa => 'Str', is => 'ro', default => 'Helvetica-Bold' );
11 3 has 'color' => ( isa => 'Str', is => 'ro', default => 'black' );
12 3 has 'value' => ( isa => 'ArrayRef', is => 'ro' );
13 3 has 'align' => ( isa => 'Str', is => 'ro' );
14  
15 3 has 'lead' => ( isa => 'Int', is => 'ro', lazy_build => 1 );
16 0 ▶sub _build_lead{
Subroutine _build_lead: not called CC=1 SCAR=6.9
17 0 my ($self) = @_;
18 0 return int($self->size + $self->size*$self->lead_spacing);
19 }
20  
21 3 has 'lead_spacing' => ( isa => 'Num', is => 'ro', lazy_build => 1 );
22 0 ▶sub _build_lead_spacing{
Subroutine _build_lead_spacing: not called CC=1 SCAR=6.9
23 0 return 20/100;
24 }
25  
26 0 ▶sub get_font{
Subroutine get_font: not called CC=2 SCAR=17.9
Pod undocumented
27 0 my ($self, $font_name) = @_;
28 0 ▶ return $self->boxer->doc->font( $font_name || $self->font );
Condition0%0/3
$font_name || $self->font
l!l&&r!l&&!r
000
MC/DC0%0/2
$font_name || $self->font
$font_name $self->font
Truth table0%0/3
A || B
A= $font_nameB= $self->font
ABresult
1X1
011
000
29 }
30  
31 0 ▶sub baseline_top{
Subroutine baseline_top: not called CC=2 SCAR=17.9
Pod undocumented
32 0 my ($self, $font, $size) = @_;
33 0 my $asc = $font->ascender();
34 0 my $desc = $font->descender();
35 0 ▶ my $adjust_perc = $asc / (($desc < 0 ? abs($desc) : $desc) + $asc);
Branch: 1 branch
BranchTrueFalseTotal
$desc < 0 ? : 0 0 0
36 0 my $adjust = $self->size*$adjust_perc;
37 0 return $self->content_top - $adjust;
38 }
39  
40 0 ▶sub prepare_text{
Subroutine prepare_text: not called CC=1 SCAR=6.9
Pod undocumented
41 0 my ($self) = @_;
42 0 my $text = $self->boxer->doc->text;
43 0 my $font = $self->get_font;
44 0 $text->font($font, $self->size);
45 0 $text->fillcolor($self->color);
46 0 $text->lead($self->lead);
47 0 return $text;
48 }
49  
50 0 ▶sub dump_attr{
Subroutine dump_attr: not called CC=4 SCAR=30.0
Pod undocumented
51 0 my ($self) = @_;
52 my @lines = (
53 '== Text Attr ==',
54 0 ▶ (sprintf 'Text: %s', "\n\t".join("\n\t", @{$self->value})),
Condition0%0/4
$self->size || 'none'
l!l
00
$self->color || 'none'
l!l
00
MC/DC0%0/1
$self->size || 'none'
$self->size
MC/DC0%0/1
$self->color || 'none'
$self->color
Truth table0%0/2
A
A= $self->size
Aresult
11
00
Truth table0%0/2
A
A= $self->color
Aresult
11
00
55 (sprintf 'Size: %s', $self->size || 'none'),
56 (sprintf 'Color: %s', $self->color || 'none'),
57 );
58 0 $_ .= "\n" foreach @lines;
59 0 return join('', @lines);
60 }
61  
62 3 1;
63  
64 __END__
« lib/PDF/Boxer/Role/SizePosition.pm ↑ Summary lib/PDF/Boxer/Doc.pm »