Font/TTF/Mort/Rearrangement.pm untested

filter: Statementstmt 0.0% 0 / 43 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 0.0% 0 / 8 Podpod 0.0% 0 / 4 totaltotal 0.0% 0 / 68 CC 5 SCAR 26.1
CC
5
Cov
0%
print
30.0
new
2.0
read
2.0
CRAP 13.7
1 package Font::TTF::Mort::Rearrangement;
2  
3 =head1 NAME
4  
5 Font::TTF::Mort::Rearrangement - Rearrangement Mort subtable for AAT
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  
16 @ISA = qw(Font::TTF::Mort::Subtable);
17  
18 sub new
19 {
20 my ($class, $direction, $orientation, $subFeatureFlags) = @_;
21 my ($self) = {
22 'direction' => $direction,
23 'orientation' => $orientation,
24 'subFeatureFlags' => $subFeatureFlags
25 };
26  
27 $class = ref($class) || $class;
28 bless $self, $class;
29 }
30  
31 =head2 $t->read
32  
33 Reads the table into memory
34  
35 =cut
36  
37 sub read
38 {
39 my ($self, $fh) = @_;
40
41 my ($classes, $states) = AAT_read_state_table($fh, 0);
42 $self->{'classes'} = $classes;
43 $self->{'states'} = $states;
44
45 $self;
46 }
47  
48 =head2 $t->pack_sub()
49  
50 =cut
51  
52 sub pack_sub
53 {
54 my ($self) = @_;
55
56 return AAT_pack_state_table($self->{'classes'}, $self->{'states'}, 0);
57 }
58  
59 =head2 $t->print($fh)
60  
61 Prints a human-readable representation of the table
62  
63 =cut
64  
65 sub print
66 {
67 my ($self, $fh) = @_;
68
69 my $post = $self->post();
70
71 $fh = 'STDOUT' unless defined $fh;
72  
73 $self->print_classes($fh);
74  
75 $fh->print("\n");
76 my $states = $self->{'states'};
77 my @verbs = ( "0", "Ax->xA", "xD->Dx", "AxD->DxA",
78 "ABx->xAB", "ABx->xBA", "xCD->CDx", "xCD->DCx",
79 "AxCD->CDxA", "AxCD->DCxA", "ABxD->DxAB", "ABxD->DxBA",
80 "ABxCD->CDxAB", "ABxCD->CDxBA", "ABxCD->DCxAB", "ABxCD->DCxBA");
81 foreach (0 .. $#$states) {
82 $fh->printf("\t\tState %d:", $_);
83 my $state = $states->[$_];
84 foreach (@$state) {
85 my $flags;
86 $flags .= "!" if ($_->{'flags'} & 0x4000);
87 $flags .= "<" if ($_->{'flags'} & 0x8000);
88 $flags .= ">" if ($_->{'flags'} & 0x2000);
89 $fh->printf("\t(%s%d,%s)", $flags, $_->{'nextState'}, $verbs[($_->{'flags'} & 0x000f)]);
90 }
91 $fh->print("\n");
92 }
93 }
94  
95 1;
96  
97 =head1 BUGS
98  
99 None known
100  
101 =head1 AUTHOR
102  
103 Jonathan Kew L<http://scripts.sil.org/FontUtils>.
104  
105  
106 =head1 LICENSING
107  
108 Copyright (c) 1998-2016, SIL International (http://www.sil.org)
109  
110 This module is released under the terms of the Artistic License 2.0.
111 For details, see the full text of the license in the file LICENSE.
112  
113  
114  
115 =cut
116  
117  
118