Font/TTF/DSIG.pm untested

filter: Statementstmt 0.0% 0 / 57 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 5 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 0.0% 0 / 8 Podpod 0.0% 0 / 4 totaltotal 0.0% 0 / 81 CC 3 SCAR 12.8
CC
3
Cov
0%
read
6.0
out
6.0
create
2.0
CRAP 3.6
1 package Font::TTF::DSIG;
2  
3 use strict;
4 use vars qw(@ISA);
5  
6 require Font::TTF::Table;
7 use Font::TTF::Utils;
8  
9 @ISA = qw(Font::TTF::Table);
10  
11 sub create
12 {
13 my ($class) = @_;
14 my ($self) = { 'version' => 1, 'numtables' => 0, 'perms' => 0 };
15 bless $self, ref $class || $class;
16 return $self;
17 }
18  
19 sub read
20 {
21 my ($self) = @_;
22 my ($dat, $i, @records, $r);
23  
24 $self->SUPER::read || return $self;
25 $self->{' INFILE'}->read($dat, 8);
26 ($self->{'version'}, $self->{'numtables'}, $self->{'perms'}) = unpack("Nnn", $dat);
27 for ($i = 0; $i < $self->{'numtables'}; $i++)
28 {
29 $self->{' INFILE'}->read($dat, 12);
30 push (@records, [unpack("N3", $dat)]);
31 }
32 foreach $r (@records)
33 {
34 if ($r->[0] == 1)
35 {
36 $self->{' INFILE'}->seek($self->{' OFFSET'} + $r->[2],0);
37 $self->{' INFILE'}->read($dat, $r->[1]);
38 push @{$self->{'records'}}, substr($dat, 8);
39 }
40 }
41 $self;
42 }
43  
44 sub isempty
45 {
46 my ($self) = @_;
47 return $self->read->{'numtables'} == 0;
48 }
49  
50 sub out
51 {
52 my ($self, $fh) = @_;
53 my ($i, $curlen);
54  
55 return $self->SUPER::out($fh) unless $self->{' read'}; # this is never true
56 $fh->print(pack("Nnn", $self->{'version'}, $self->{'numtables'}, $self->{'perms'}));
57 $curlen = 0;
58 for ($i = 0; $i < $self->{'numtables'}; $i++)
59 {
60 $fh->print(pack("N3", 1, length($self->{'records'}[$i]) + 8, $curlen + $self->{'numtables'} * 12 + 8));
61 $curlen += length($self->{'records'}[$i]) + 8;
62 }
63 for ($i = 0; $i < $self->{'numtables'}; $i++)
64 {
65 $fh->print(pack("nnN", 0, 0, length($self->{'records'}[$i])));
66 $fh->print($self->{'records'}[$i]);
67 }
68 $self;
69 }
70  
71 1;
72  
73 =head1 AUTHOR
74  
75 Martin Hosken L<http://scripts.sil.org/FontUtils>.
76  
77  
78 =head1 LICENSING
79  
80 Copyright (c) 1998-2016, SIL International (http://www.sil.org)
81  
82 This module is released under the terms of the Artistic License 2.0.
83 For details, see the full text of the license in the file LICENSE.
84  
85  
86  
87 =cut
88