File Coverage

blib/lib/PDF/Make/Font.pm
Criterion Covered Total %
statement 18 20 90.0
branch 4 6 66.6
condition 4 6 66.6
subroutine 6 6 100.0
pod 3 3 100.0
total 35 41 85.3


line stmt bran cond sub pod time code
1             package PDF::Make::Font;
2 48     48   477995 use strict;
  48         58  
  48         1366  
3 48     48   149 use warnings;
  48         58  
  48         3164  
4              
5             our $VERSION = '0.03';
6              
7             # Load the XS via PDF::Make
8             require PDF::Make;
9              
10             # Font types
11             use constant {
12 48         14395 TYPE_TYPE1 => 0,
13             TYPE_TRUETYPE => 1,
14             TYPE_CID_TRUETYPE => 2,
15 48     48   248 };
  48         68  
16              
17             # Standard 14 font names
18             our @STD14_NAMES = qw(
19             Helvetica
20             Helvetica-Bold
21             Helvetica-Oblique
22             Helvetica-BoldOblique
23             Times-Roman
24             Times-Bold
25             Times-Italic
26             Times-BoldItalic
27             Courier
28             Courier-Bold
29             Courier-Oblique
30             Courier-BoldOblique
31             Symbol
32             ZapfDingbats
33             );
34              
35             sub new {
36 22     22 1 273909 my ($class, %opts) = @_;
37            
38 22 50 100     148 if (my $file = $opts{file}) {
    50          
    100          
39 0         0 return $class->from_file($file, $opts{arena});
40             }
41             elsif (my $bytes = $opts{bytes}) {
42 0         0 return $class->from_bytes($bytes, $opts{arena});
43             }
44             elsif (my $std14 = $opts{standard14} // $opts{std14}) {
45 19         312 return $class->standard14($std14, $opts{arena});
46             }
47             else {
48 3         38 require Carp;
49 3         525 Carp::croak("PDF::Make::Font: must specify file, bytes, or standard14");
50             }
51             }
52              
53             sub is_standard14 {
54 6     6 1 142770 my $self = shift;
55 6         52 return $self->type == TYPE_TYPE1;
56             }
57              
58             sub is_truetype {
59 4     4 1 34 my $self = shift;
60 4   33     56 return $self->type == TYPE_TRUETYPE || $self->type == TYPE_CID_TRUETYPE;
61             }
62              
63             1;
64              
65             __END__