TextBlock/Font.pm

filter: Statementstmt 100% 29 / 29 Branchbran 75.0% 3 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 8 / 8 Podpod 100% 1 / 1 totaltotal 97.6% 41 / 42 CC 4 SCAR 7.4
CC
4
Cov
97%
apply_defaults
4.0
BEGIN
1.0
BEGIN
1.0
CRAP 2.1
« TextBlock.pm ↑ Summary
1 package PDF::TextBlock::Font;
2  
3 7 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 7 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 7 ▶use Class::Accessor::Fast;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 7 ▶use base qw( Class::Accessor::Fast );
Subroutine BEGIN: called CC=1 SCAR=0.0
8 7 __PACKAGE__->mk_accessors(qw( pdf font fillcolor size ));
9  
10 7 ▶use constant mm => 25.4 / 72;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 7 ▶use constant in => 1 / 72;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 7 ▶use constant pt => 1;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 7 our $VERSION = '0.04';
15  
16 =head1 NAME
17  
18 PDF::TextBlock::Font - A font object to override the defaults PDF::TextBlock uses
19  
20 =head1 SYNOPSIS
21  
22 TODO add from t/*
23  
24 =head1 DESCRIPTION
25  
26 You can hand PDF::TextBlock objects from this class whenever you want to override
27 the font defaults.
28  
29 =head1 METHODS
30  
31 =head2 apply_defaults
32  
33 Applies defaults for you wherever you didn't explicitly set a different value.
34  
35 =cut
36  
37 34 ▶sub apply_defaults {
Subroutine apply_defaults: called CC=4 SCAR=13.9
Pod documented
38 34 my ($self) = @_;
39 34 ▶ die "pdf attribute (your PDF::API object) required" unless $self->pdf;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->pdf 0 34 34
40 34 my %defaults = (
41 # font is a PDF::API2::Resource::Font::CoreFont (or PDF::Builder)
42 font => $self->pdf->corefont( 'Helvetica', -encoding => 'latin1' ),
43 fillcolor => 'black',
44 size => 10 / pt,
45 );
46 34 foreach my $att (keys %defaults) {
47 102 ▶ $self->$att($defaults{$att}) unless defined $self->$att;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->$att 24 78 102
48 }
49  
50 #my %fonts = (
51 # Helvetica => {
52 # Bold => $pdf->corefont( 'Helvetica-Bold', -encoding => 'latin1' ),
53 # Roman => $pdf->corefont( 'Helvetica', -encoding => 'latin1' ),
54 # Italic => $pdf->corefont( 'Helvetica-Oblique', -encoding => 'latin1' ),
55 # },
56 # Gotham => {
57 # Bold => $pdf->ttfont('Gotham-Bold.ttf', -encode => 'latin1'),
58 # Roman => $pdf->ttfont('Gotham-Light.otf', -encode => 'latin1'),
59 # },
60 #);
61 }
62  
63  
64 =head1 AUTHOR
65  
66 Jay Hannah, C<< <jay at jays.net> >>
67  
68 =head1 BUGS / SUPPORT
69  
70 See PDF::TextBlock.
71  
72 =head1 COPYRIGHT & LICENSE
73  
74 Copyright 2009-2013 Jay Hannah, all rights reserved.
75  
76 This program is free software; you can redistribute it and/or modify it
77 under the same terms as Perl itself.
78  
79 =cut
80  
81 7 1; # End of PDF::TextBlock::Font
« TextBlock.pm ↑ Summary