Font/TTF/Mort.pm untested

filter: Statementstmt 0.0% 0 / 48 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 0.0% 0 / 9 Podpod 0.0% 0 / 4 totaltotal 0.0% 0 / 70 CC 4 SCAR 16.4
CC
4
Cov
0%
print
12.0
out
6.0
read
2.0
CRAP 5.2
1 package Font::TTF::Mort;
2  
3 =head1 NAME
4  
5 Font::TTF::Mort - Glyph Metamorphosis table in a font
6  
7 =head1 METHODS
8  
9 =cut
10  
11 use strict;
12 use vars qw(@ISA);
13 use Font::TTF::Utils;
14 use Font::TTF::AATutils;
15 use Font::TTF::Mort::Chain;
16  
17 @ISA = qw(Font::TTF::Table);
18  
19 =head2 $t->read
20  
21 Reads the table into memory
22  
23 =cut
24  
25 sub read
26 {
27 my ($self) = @_;
28 my ($dat, $fh, $numChains);
29
30 $self->SUPER::read or return $self;
31  
32 $fh = $self->{' INFILE'};
33  
34 $fh->read($dat, 8);
35 ($self->{'version'}, $numChains) = TTF_Unpack("vL", $dat);
36
37 my $chains = [];
38 foreach (1 .. $numChains) {
39 my $chain = new Font::TTF::Mort::Chain->new;
40 $chain->read($fh);
41 $chain->{' PARENT'} = $self;
42 push @$chains, $chain;
43 }
44  
45 $self->{'chains'} = $chains;
46  
47 $self;
48 }
49  
50 =head2 $t->out($fh)
51  
52 Writes the table to a file either from memory or by copying
53  
54 =cut
55  
56 sub out
57 {
58 my ($self, $fh) = @_;
59
60 return $self->SUPER::out($fh) unless $self->{' read'};
61  
62 my $chains = $self->{'chains'};
63 $fh->print(TTF_Pack("vL", $self->{'version'}, scalar @$chains));
64  
65 foreach (@$chains) {
66 $_->out($fh);
67 }
68 }
69  
70 =head2 $t->minsize()
71  
72 Returns the minimum size this table can be. If it is smaller than this, then the table
73 must be bad and should be deleted or whatever.
74  
75 =cut
76  
77 sub minsize
78 {
79 return 8;
80 }
81  
82 =head2 $t->print($fh)
83  
84 Prints a human-readable representation of the table
85  
86 =cut
87  
88 sub print
89 {
90 my ($self, $fh) = @_;
91
92 $self->read unless $self->{' read'};
93 my $feat = $self->{' PARENT'}->{'feat'};
94 $feat->read;
95 my $post = $self->{' PARENT'}->{'post'};
96 $post->read;
97
98 $fh = 'STDOUT' unless defined $fh;
99  
100 $fh->printf("version %f\n", $self->{'version'});
101
102 my $chains = $self->{'chains'};
103 foreach (@$chains) {
104 $_->print($fh);
105 }
106 }
107  
108 1;
109  
110 =head1 BUGS
111  
112 None known
113  
114 =head1 AUTHOR
115  
116 Jonathan Kew L<http://scripts.sil.org/FontUtils>.
117  
118  
119 =head1 LICENSING
120  
121 Copyright (c) 1998-2016, SIL International (http://www.sil.org)
122  
123 This module is released under the terms of the Artistic License 2.0.
124 For details, see the full text of the license in the file LICENSE.
125  
126  
127  
128 =cut
129  
130