1 package Font::TTF::Kern::ClassArray;
5 Font::TTF::Kern::ClassArray - ClassArray Kern Subtable for AAT
14 use Font::TTF::AATutils;
17 @ISA = qw(Font::TTF::Kern::Subtable);
24 $class = ref($class) || $class;
30 Reads the table into memory
38 my $subtableStart = $fh->tell() - 8;
41 my ($rowWidth, $leftClassTable, $rightClassTable, $array) = unpack("nnnn", $dat);
43 $fh->seek($subtableStart + $leftClassTable, IO::File::SEEK_SET);
45 my ($firstGlyph, $nGlyphs) = unpack("nn", $dat);
46 $fh->read($dat, $nGlyphs * 2);
48 foreach (TTF_Unpack("S*", $dat)) {
49 push @{$leftClasses->[($_ - $array) / $rowWidth]}, $firstGlyph++;
52 $fh->seek($subtableStart + $rightClassTable, IO::File::SEEK_SET);
54 ($firstGlyph, $nGlyphs) = unpack("nn", $dat);
55 $fh->read($dat, $nGlyphs * 2);
56 my $rightClasses = [];
57 foreach (TTF_Unpack("S*", $dat)) {
58 push @{$rightClasses->[$_ / 2]}, $firstGlyph++;
61 $fh->seek($subtableStart + $array, IO::File::SEEK_SET);
62 $fh->read($dat, $self->{'length'} - $array);
66 while ($offset < length($dat)) {
67 push @$kernArray, [ TTF_Unpack("s*", substr($dat, $offset, $rowWidth)) ];
71 $self->{'leftClasses'} = $leftClasses;
72 $self->{'rightClasses'} = $rightClasses;
73 $self->{'kernArray'} = $kernArray;
75 $fh->seek($subtableStart + $self->{'length'}, IO::File::SEEK_SET);
80 =head2 $t->out_sub($fh)
82 Writes the table to a file
92 Prints a human-readable representation of the table
100 my $post = $self->post();
102 $fh = 'STDOUT' unless defined $fh;
109 my ($self, $fh) = @_;
110 my $post = $self->post();
112 $fh = 'STDOUT' unless defined $fh;
113 $fh->printf("<leftClasses>\n");
114 $self->dumpClasses($self->{'leftClasses'}, $fh);
115 $fh->printf("</leftClasses>\n");
117 $fh->printf("<rightClasses>\n");
118 $self->dumpClasses($self->{'rightClasses'}, $fh);
119 $fh->printf("</rightClasses>\n");
121 $fh->printf("<kernArray>\n");
122 my $kernArray = $self->{'kernArray'};
123 foreach (0 .. $#$kernArray) {
124 $fh->printf("<row index=\"%s\">\n", $_);
125 my $row = $kernArray->[$_];
126 foreach (0 .. $#$row) {
127 $fh->printf("<val index=\"%s\" v=\"%s\"/>\n", $_, $row->[$_]);
129 $fh->printf("</row>\n");
131 $fh->printf("</kernArray>\n");
136 return 'kernClassArray';
149 Jonathan Kew L<Jonathan_Kew@sil.org>. See L<Font::TTF::Font> for copyright and