line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package PDF::Boxer::Role::Text; |
2
|
|
|
|
|
|
|
{ |
3
|
|
|
|
|
|
|
$PDF::Boxer::Role::Text::VERSION = '0.001'; # TRIAL |
4
|
|
|
|
|
|
|
} |
5
|
3
|
|
|
3
|
|
1436
|
use Moose::Role; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
25
|
|
6
|
|
|
|
|
|
|
# ABSTRACT: methods & attributes for text boxes |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
has 'size' => ( isa => 'Int', is => 'ro', default => 14 ); |
9
|
|
|
|
|
|
|
has 'font' => ( isa => 'Str', is => 'ro', default => 'Helvetica' ); |
10
|
|
|
|
|
|
|
has 'font_bold' => ( isa => 'Str', is => 'ro', default => 'Helvetica-Bold' ); |
11
|
|
|
|
|
|
|
has 'color' => ( isa => 'Str', is => 'ro', default => 'black' ); |
12
|
|
|
|
|
|
|
has 'value' => ( isa => 'ArrayRef', is => 'ro' ); |
13
|
|
|
|
|
|
|
has 'align' => ( isa => 'Str', is => 'ro' ); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
has 'lead' => ( isa => 'Int', is => 'ro', lazy_build => 1 ); |
16
|
|
|
|
|
|
|
sub _build_lead{ |
17
|
0
|
|
|
0
|
|
|
my ($self) = @_; |
18
|
0
|
|
|
|
|
|
return int($self->size + $self->size*$self->lead_spacing); |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
has 'lead_spacing' => ( isa => 'Num', is => 'ro', lazy_build => 1 ); |
22
|
|
|
|
|
|
|
sub _build_lead_spacing{ |
23
|
0
|
|
|
0
|
|
|
return 20/100; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub get_font{ |
27
|
0
|
|
|
0
|
0
|
|
my ($self, $font_name) = @_; |
28
|
0
|
|
0
|
|
|
|
return $self->boxer->doc->font( $font_name || $self->font ); |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub baseline_top{ |
32
|
0
|
|
|
0
|
0
|
|
my ($self, $font, $size) = @_; |
33
|
0
|
|
|
|
|
|
my $asc = $font->ascender(); |
34
|
0
|
|
|
|
|
|
my $desc = $font->descender(); |
35
|
0
|
0
|
|
|
|
|
my $adjust_perc = $asc / (($desc < 0 ? abs($desc) : $desc) + $asc); |
36
|
0
|
|
|
|
|
|
my $adjust = $self->size*$adjust_perc; |
37
|
0
|
|
|
|
|
|
return $self->content_top - $adjust; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub prepare_text{ |
41
|
0
|
|
|
0
|
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
|
|
|
|
|
|
|
sub dump_attr{ |
51
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
52
|
|
|
|
|
|
|
my @lines = ( |
53
|
|
|
|
|
|
|
'== Text Attr ==', |
54
|
0
|
|
0
|
|
|
|
(sprintf 'Text: %s', "\n\t".join("\n\t", @{$self->value})), |
|
0
|
|
0
|
|
|
|
|
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
|
|
|
|
|
|
|
1; |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
__END__ |
65
|
|
|
|
|
|
|
=pod |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head1 NAME |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
PDF::Boxer::Role::Text - methods & attributes for text boxes |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head1 VERSION |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
version 0.001 |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head1 AUTHOR |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
Jason Galea <lecstor@cpan.org> |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
This software is copyright (c) 2011 by Jason Galea. |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
84
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=cut |
87
|
|
|
|
|
|
|
|