File Coverage

blib/lib/PDF/Make/Builder/Text/H2.pm
Criterion Covered Total %
statement 19 19 100.0
branch 2 2 100.0
condition 4 7 57.1
subroutine 5 5 100.0
pod 1 1 100.0
total 31 34 91.1


line stmt bran cond sub pod time code
1             package PDF::Make::Builder::Text::H2;
2 42     42   209 use strict;
  42         62  
  42         1348  
3 42     42   171 use warnings;
  42         127  
  42         1608  
4 42     42   151 use Object::Proto;
  42         52  
  42         2553  
5              
6             BEGIN {
7 42     42   3921 Object::Proto::define('PDF::Make::Builder::Text::H2',
8             extends => 'PDF::Make::Builder::Text',
9             'toc:Bool:default(0)',
10             );
11 42         8091 Object::Proto::import_accessors('PDF::Make::Builder::Text::H2');
12             }
13              
14             sub add {
15 5     5 1 10 my ($self, $builder) = @_;
16 5         14 my $f = font $self // {};
17 5   50     24 $f->{size} //= 40;
18 5   50     17 $f->{line_height} //= 48;
19 5         32 font $self, $f;
20              
21 5 100 66     23 if ($self->toc && $builder->toc) {
22 3         15 $builder->toc->outline($builder, 2,
23             text => PDF::Make::Builder::Text::text($self),
24             page_num => $builder->page->num,
25             );
26             }
27              
28 5         18 return $self->SUPER::add($builder);
29             }
30              
31             1;
32              
33             __END__