API3/Compat/API2/Basic/TTF/Kern/StateTable.pm untested

filter: Statementstmt 0.0% 0 / 68 Branchbran 0.0% 0 / 14 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 0.0% 0 / 11 Podpod 0.0% 0 / 6 totaltotal 0.0% 0 / 104 CC 8 SCAR 26.2
CC
8
Cov
0%
read
30.0
dumpXML
20.0
new
2.0
CRAP 13.8
1 #=======================================================================
2 # ____ ____ _____ _ ____ ___ ____
3 # | _ \| _ \| ___| _ _ / \ | _ \_ _| |___ \
4 # | |_) | | | | |_ (_) (_) / _ \ | |_) | | __) |
5 # | __/| |_| | _| _ _ / ___ \| __/| | / __/
6 # |_| |____/|_| (_) (_) /_/ \_\_| |___| |_____|
7 #
8 # A Perl Module Chain to faciliate the Creation and Modification
9 # of High-Quality "Portable Document Format (PDF)" Files.
10 #
11 #=======================================================================
12 #
13 # THIS IS A REUSED PERL MODULE, FOR PROPER LICENCING TERMS SEE BELOW:
14 #
15 #
16 # Copyright Jonathan Kew L<Jonathan_Kew@sil.org>.
17 #
18 # No warranty or expression of effectiveness, least of all regarding
19 # anyone's safety, is implied in this software or documentation.
20 #
21 # This specific module is licensed under the Perl Artistic License.
22 #
23 #
24 # $Id: StateTable.pm,v 2.0 2005/11/16 02:16:00 areibens Exp $
25 #
26 #=======================================================================
27 package PDF::API3::Compat::API2::Basic::TTF::Kern::StateTable;
28
29 =head1 NAME
30
31 PDF::API3::Compat::API2::Basic::TTF::Kern::StateTable
32
33 =head1 METHODS
34
35 =cut
36
37 use strict;
38 use vars qw(@ISA);
39 use PDF::API3::Compat::API2::Basic::TTF::Utils;
40 use PDF::API3::Compat::API2::Basic::TTF::AATutils;
41 use PDF::API3::Compat::API2::Basic::TTF::Kern::Subtable;
42
43 @ISA = qw(PDF::API3::Compat::API2::Basic::TTF::Kern::Subtable);
44
45 sub new
46 {
47 my ($class) = @_;
48 my ($self) = {};
49
50 $class = ref($class) || $class;
51 bless $self, $class;
52 }
53
54 =head2 $t->read
55
56 Reads the table into memory
57
58 =cut
59
60 sub read
61 {
62 my ($self, $fh) = @_;
63 my ($dat);
64
65 my $stTableStart = $fh->tell();
66
67 my ($classes, $states, $entries) = AAT_read_state_table($fh, 0);
68
69 foreach (@$entries) {
70 my $flags = $_->{'flags'};
71 delete $_->{'flags'};
72 $_->{'push'} = 1 if $flags & 0x8000;
73 $_->{'noAdvance'} = 1 if $flags & 0x4000;
74 $flags &= ~0xC000;
75 if ($flags != 0) {
76 my $kernList = [];
77 $fh->seek($stTableStart + $flags, IO::File::SEEK_SET);
78 while (1) {
79 $fh->read($dat, 2);
80 my $k = TTF_Unpack("s", $dat);
81 push @$kernList, ($k & ~1);
82 last if ($k & 1) != 0;
83 }
84 $_->{'kernList'} = $kernList;
85 }
86 }
87
88 $self->{'classes'} = $classes;
89 $self->{'states'} = $states;
90 $self->{'entries'} = $entries;
91
92 $fh->seek($stTableStart - 8 + $self->{'length'}, IO::File::SEEK_SET);
93
94 $self;
95 }
96
97 =head2 $t->out_sub($fh)
98
99 Writes the table to a file
100
101 =cut
102
103 sub out_sub
104 {
105 }
106
107 =head2 $t->print($fh)
108
109 Prints a human-readable representation of the table
110
111 =cut
112
113 sub print
114 {
115 }
116
117 sub dumpXML
118 {
119 my ($self, $fh) = @_;
120
121 $fh->printf("<classes>\n");
122 $self->dumpClasses($self->{'classes'}, $fh);
123 $fh->printf("</classes>\n");
124
125 $fh->printf("<states>\n");
126 my $states = $self->{'states'};
127 foreach (0 .. $#$states) {
128 $fh->printf("<state index=\"%s\">\n", $_);
129 my $members = $states->[$_];
130 foreach (0 .. $#$members) {
131 my $m = $members->[$_];
132 $fh->printf("<m index=\"%s\" nextState=\"%s\"", $_, $m->{'nextState'});
133 $fh->printf(" push=\"1\"") if $m->{'push'};
134 $fh->printf(" noAdvance=\"1\"") if $m->{'noAdvance'};
135 if (exists $m->{'kernList'}) {
136 $fh->printf(">");
137 foreach (@{$m->{'kernList'}}) {
138 $fh->printf("<kern v=\"%s\"/>", $_);
139 }
140 $fh->printf("</m>\n");
141 }
142 else {
143 $fh->printf("/>\n");
144 }
145 }
146 $fh->printf("</state>\n");
147 }
148 $fh->printf("</states>\n");
149 }
150
151 sub type
152 {
153 return 'kernStateTable';
154 }
155
156 1;
157
158 =head1 BUGS
159
160 None known
161
162 =head1 AUTHOR
163
164 Jonathan Kew L<Jonathan_Kew@sil.org>. See L<PDF::API3::Compat::API2::Basic::TTF::Font> for copyright and
165 licensing.
166
167 =cut
168